get_comment_time()
Retrieve the comment time of the current comment.
Uses: mysql2date()
Used By: comment_time()
Hooks from the function
Return
String
. The formatted time.
Usage
get_comment_time( $format, $gmt, $translate, $comment_id );
- $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 - $comment_id(int|WP_Comment)
- WP_Comment or ID of the comment for which to get the time.
Default: current comment
Examples
#1 Examples of Different Time Formats
echo get_comment_time( 'h:i:s A' ); // 03:08:46 PM echo get_comment_time( 'g:i:s a' ); // 3:08:46 pm echo get_comment_time( 'Hi' ); // 0800 (24 hour time) echo get_comment_time( 'Gi' ); // 800 (24 hour time)
See also: WordPress time formats.
#2 Publication time of the current comment
In the format 22:04:11
. The code should be used inside the comment loop, usually the built-in function specified in the callback
parameter of the wp_list_comments().
<p>Comment publishing time: <?php get_comment_time('H:i:s'); ?></p>
Changelog
Since 1.5.0 | Introduced. |
Since 6.2.0 | Added the $comment_id parameter. |