WordPress at a glance

get_comment_time() WP 1.0

Retrieve the comment time of the current comment.

Is the basis for: comment_time()
Works based on: mysql2date()
Hooks from the function

String. The formatted time.


get_comment_time( $format, $gmt, $translate );
The format of the time.
Default: user's settings
Whether to use the GMT date.
Default: false
Whether to translate the time (for use in feeds).
Default: true


Since 1.5.0 Introduced.

Code of get comment time: wp-includes/comment-template.php WP 5.4.2

function get_comment_time( $format = '', $gmt = false, $translate = true ) {
	$comment = get_comment();

	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
	if ( '' == $format ) {
		$date = mysql2date( get_option( 'time_format' ), $comment_date, $translate );
	} else {
		$date = mysql2date( $format, $comment_date, $translate );

	 * Filters the returned comment time.
	 * @since 1.5.0
	 * @param string|int $date      The comment time, formatted as a date string or Unix timestamp.
	 * @param string     $format    Date format.
	 * @param bool       $gmt       Whether the GMT date is in use.
	 * @param bool       $translate Whether the time is translated.
	 * @param WP_Comment $comment   The comment object.
	return apply_filters( 'get_comment_time', $date, $format, $gmt, $translate, $comment );

Related Functions

From tag: date time

More from category: Comments Loop

No comments
        Log In . Register