On this page
get_comment_time( string $format = '', bool $gmt = false, bool $translate = true ): string
Retrieves the comment time of the current comment.
Parameters
$formatstring Optional-
PHP time format. Defaults to the
'time_format'option.Default:
'' $gmtbool Optional-
Whether to use the GMT date.
Default:
false $translatebool Optional-
Whether to translate the time (for use in feeds).
Default:
true
Return
string The formatted time.
Source
File: wp-includes/comment-template.php. View all references
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 );
}
Hooks
- apply_filters( 'get_comment_time',
string|int $date ,string $format ,bool $gmt ,bool $translate ,WP_Comment $comment ) -
Filters the returned comment time.
Related
Uses
| Uses | Description |
|---|---|
| mysql2date() wp-includes/functions.php | Converts given MySQL date string into a different format. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
| get_comment() wp-includes/comment.php | Retrieves comment data given a comment ID or comment object. |
Used By
| Used By | Description |
|---|---|
| Walker_Comment::comment() wp-includes/class-walker-comment.php | Outputs a single comment. |
| Walker_Comment::html5_comment() wp-includes/class-walker-comment.php | Outputs a comment in the HTML5 format. |
| comment_time() wp-includes/comment-template.php | Displays the comment time of the current comment. |
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_comment_time