get_comment_time( string $format = '', bool $gmt = false, bool $translate = true, int|WP_Comment $comment_id )
Retrieves the comment time of the current comment.
Parameters
- $format
-
(Optional) PHP date format. Defaults to the 'time_format' option.
Default value: ''
- $gmt
-
(Optional) Whether to use the GMT date.
Default value: false
- $translate
-
(Optional) Whether to translate the time (for use in feeds).<br>
Default value: true
- $comment_id
-
(Optional) WP_Comment or ID of the comment for which to get the time.<br> Default current comment.
Return
(string) The formatted time.
Source
File: wp-includes/comment-template.php
function get_comment_time( $d = '', $gmt = false, $translate = true ) {
$comment = get_comment();
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
if ( '' == $d )
$date = mysql2date(get_option('time_format'), $comment_date, $translate);
else
$date = mysql2date($d, $comment_date, $translate);
/**
* Filters the returned comment time.
*
* @since WP-1.5.0
*
* @param string|int $date The comment time, formatted as a date string or Unix timestamp.
* @param string $d 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, $d, $gmt, $translate, $comment );
}
Changelog
Version | Description |
---|---|
6.2.0 | Added the $comment_id parameter. |
1.5.0 | Introduced. |