WordPress at a glance

get_comment_date() WP 1.0

Retrieve the comment date of the current comment.

  • Since 4.4.0 Added the ability for $comment_ID to also accept a WP_Comment object.
Is the basis for: comment_date()
Works based on: mysql2date()

No Hooks.

Return

String. The comment's date.

Usage

get_comment_date( $d, $comment_ID );
$d(string)
The format of the date.
Default: user's setting
$comment_ID(int/WP_Comment)
WP_Comment or ID of the comment for which to get the date.
Default: current comment

Code of get_comment_date: wp-includes/comment-template.php VER 5.0.1

<?php
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 );
}

Related Functions

From tag: date time

More from category: Comments Loop

No comments
    Hello, !     Log In . Register