get_comment_time() WP 1.0
Retrieve the comment time of the current comment.
Return
String. The formatted time.
Usage
get_comment_time( $format, $gmt, $translate );
- $format(string)
- PHP date format. option.
Default: 'time_format'
- $gmt(true/false)
- Whether to use the GMT date.
Default: false
- $translate(true/false)
- Whether to translate the time (for use in feeds).
Default: true
Changelog
Code of get_comment_time() get comment time
WP 5.6.2
<?php
function get_comment_time( $format = '', $gmt = false, $translate = true ) {
$comment = get_comment();
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
$_format = ! empty( $format ) ? $format : get_option( 'time_format' );
$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 PHP 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