get_comment_time() WordPress Function
The get_comment_time() function in WordPress gets the current comment time. The time is returned as a formatted string.
get_comment_time( string $format = '', bool $gmt = false, bool $translate = true ) #
Retrieves the comment time of the current comment.
Parameters
- $format
(string)(Optional) PHP time format. Defaults to the 'time_format' option.
Default value: ''
- $gmt
(bool)(Optional) Whether to use the GMT date.
Default value: false
- $translate
(bool)(Optional) Whether to translate the time (for use in feeds).
Default value: true
Return
(string) The formatted time.
Source
File: wp-includes/comment-template.php
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 | 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 ); } |
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
1.5.0 | Introduced. |