get_comment_date

The timeline below displays how wordpress function get_comment_date has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Retrieves the comment date of the current comment.
 *
 * @since 1.5.0
 * @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
 *
 * @param string         $format     Optional. PHP date format. Defaults to the 'date_format' option.
 * @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the date.
 *                                   Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($format = '', $comment_id = 0)
{
    $comment = get_comment($comment_id);
    $_format = (!empty($format)) ? $format : get_option('date_format');
    $comment_date = mysql2date($_format, $comment->comment_date);
    /**
     * Filters the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $comment_date Formatted date string or Unix timestamp.
     * @param string     $format       PHP date format.
     * @param WP_Comment $comment      The comment object.
     */
    return apply_filters('get_comment_date', $comment_date, $format, $comment);
}

WordPress Version: 6.2

/**
 * Retrieves the comment date of the current comment.
 *
 * @since 1.5.0
 * @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
 *
 * @param string         $format     Optional. PHP date format. Defaults to the 'date_format' option.
 * @param int|WP_Comment $comment_id Optional. WP_Comment or ID of the comment for which to get the date.
 *                                   Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($format = '', $comment_id = 0)
{
    $comment = get_comment($comment_id);
    $_format = (!empty($format)) ? $format : get_option('date_format');
    $date = mysql2date($_format, $comment->comment_date);
    /**
     * Filters the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $date    Formatted date string or Unix timestamp.
     * @param string     $format  PHP date format.
     * @param WP_Comment $comment The comment object.
     */
    return apply_filters('get_comment_date', $date, $format, $comment);
}

WordPress Version: 5.6

/**
 * Retrieves the comment date of the current comment.
 *
 * @since 1.5.0
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
 *
 * @param string         $format     Optional. PHP date format. Defaults to the 'date_format' option.
 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date.
 *                                   Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($format = '', $comment_ID = 0)
{
    $comment = get_comment($comment_ID);
    $_format = (!empty($format)) ? $format : get_option('date_format');
    $date = mysql2date($_format, $comment->comment_date);
    /**
     * Filters the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $date    Formatted date string or Unix timestamp.
     * @param string     $format  PHP date format.
     * @param WP_Comment $comment The comment object.
     */
    return apply_filters('get_comment_date', $date, $format, $comment);
}

WordPress Version: 5.1

/**
 * Retrieves the comment date of the current comment.
 *
 * @since 1.5.0
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
 *
 * @param string         $format     Optional. The format of the date. Default user's setting.
 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date.
 *                                   Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($format = '', $comment_ID = 0)
{
    $comment = get_comment($comment_ID);
    $_format = (!empty($format)) ? $format : get_option('date_format');
    $date = mysql2date($_format, $comment->comment_date);
    /**
     * Filters the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $date    Formatted date string or Unix timestamp.
     * @param string     $format  The format of the date.
     * @param WP_Comment $comment The comment object.
     */
    return apply_filters('get_comment_date', $date, $format, $comment);
}

WordPress Version: 5.5

/**
 * Retrieves the comment date of the current comment.
 *
 * @since 1.5.0
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
 *
 * @param string         $format     Optional. The format of the date. Default user's setting.
 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date.
 *                                   Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($format = '', $comment_ID = 0)
{
    $comment = get_comment($comment_ID);
    if ('' === $format) {
        $date = mysql2date(get_option('date_format'), $comment->comment_date);
    } else {
        $date = mysql2date($format, $comment->comment_date);
    }
    /**
     * Filters the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $date    Formatted date string or Unix timestamp.
     * @param string     $format  The format of the date.
     * @param WP_Comment $comment The comment object.
     */
    return apply_filters('get_comment_date', $date, $format, $comment);
}

WordPress Version: 5.4

/**
 * Retrieves the comment date of the current comment.
 *
 * @since 1.5.0
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
 *
 * @param string          $format     Optional. The format of the date. Default user's setting.
 * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to get the date.
 *                                    Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($format = '', $comment_ID = 0)
{
    $comment = get_comment($comment_ID);
    if ('' == $format) {
        $date = mysql2date(get_option('date_format'), $comment->comment_date);
    } else {
        $date = mysql2date($format, $comment->comment_date);
    }
    /**
     * Filters the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $date    Formatted date string or Unix timestamp.
     * @param string     $format  The format of the date.
     * @param WP_Comment $comment The comment object.
     */
    return apply_filters('get_comment_date', $date, $format, $comment);
}

WordPress Version: 4.6

/**
 * Retrieve the comment date of the current comment.
 *
 * @since 1.5.0
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
 *
 * @param string          $d          Optional. The format of the date. Default user's setting.
 * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to get the date.
 *                                    Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($d = '', $comment_ID = 0)
{
    $comment = get_comment($comment_ID);
    if ('' == $d) {
        $date = mysql2date(get_option('date_format'), $comment->comment_date);
    } else {
        $date = mysql2date($d, $comment->comment_date);
    }
    /**
     * Filters the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $date    Formatted date string or Unix timestamp.
     * @param string     $d       The format of the date.
     * @param WP_Comment $comment The comment object.
     */
    return apply_filters('get_comment_date', $date, $d, $comment);
}

WordPress Version: 4.4

/**
 * Retrieve the comment date of the current comment.
 *
 * @since 1.5.0
 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
 *
 * @param string          $d          Optional. The format of the date. Default user's setting.
 * @param int|WP_Comment  $comment_ID WP_Comment or ID of the comment for which to get the date.
 *                                    Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($d = '', $comment_ID = 0)
{
    $comment = get_comment($comment_ID);
    if ('' == $d) {
        $date = mysql2date(get_option('date_format'), $comment->comment_date);
    } else {
        $date = mysql2date($d, $comment->comment_date);
    }
    /**
     * Filter the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $date    Formatted date string or Unix timestamp.
     * @param string     $d       The format of the date.
     * @param WP_Comment $comment The comment object.
     */
    return apply_filters('get_comment_date', $date, $d, $comment);
}

WordPress Version: 3.9

/**
 * Retrieve the comment date of the current comment.
 *
 * @since 1.5.0
 *
 * @param string $d          Optional. The format of the date. Default user's setting.
 * @param int    $comment_ID ID of the comment for which to get the date. Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($d = '', $comment_ID = 0)
{
    $comment = get_comment($comment_ID);
    if ('' == $d) {
        $date = mysql2date(get_option('date_format'), $comment->comment_date);
    } else {
        $date = mysql2date($d, $comment->comment_date);
    }
    /**
     * Filter the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $date    Formatted date string or Unix timestamp.
     * @param string     $d       The format of the date.
     * @param object     $comment The comment object.
     */
    return apply_filters('get_comment_date', $date, $d, $comment);
}

WordPress Version: 3.8

/**
 * Retrieve the comment date of the current comment.
 *
 * @since 1.5.0
 *
 * @param string $d          Optional. The format of the date. Default user's setting.
 * @param int    $comment_ID Optional. The ID of the comment for which to get the date. Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($d = '', $comment_ID = 0)
{
    $comment = get_comment($comment_ID);
    if ('' == $d) {
        $date = mysql2date(get_option('date_format'), $comment->comment_date);
    } else {
        $date = mysql2date($d, $comment->comment_date);
    }
    /**
     * Filter the returned comment date.
     *
     * @since 1.5.0
     *
     * @param string|int $date Formatted date string or Unix timestamp.
     * @param string     $d    The format of the date.
     */
    return apply_filters('get_comment_date', $date, $d);
}

WordPress Version: 3.7

/**
 * Retrieve the comment date of the current comment.
 *
 * @since 1.5.0
 *
 * @param string $d          Optional. The format of the date. Default user's setting.
 * @param int    $comment_ID Optional. The ID of the comment for which to get the date. Default current comment.
 * @return string The comment's date.
 */
function get_comment_date($d = '', $comment_ID = 0)
{
    $comment = get_comment($comment_ID);
    if ('' == $d) {
        $date = mysql2date(get_option('date_format'), $comment->comment_date);
    } else {
        $date = mysql2date($d, $comment->comment_date);
    }
    /**
     * Filter the returned comment date.
     *
     * @since 1.5.2
     *
     * @param string|int $date Formatted date string or Unix timestamp.
     * @param string     $d    The format of the date.
     */
    return apply_filters('get_comment_date', $date, $d);
}