get_comment_time()
Gets the publication time of the current comment. Used inside the comments loop.
Uses: mysql2date()
Used By: comment_time()
Hooks from the function
Returns
String. Formatted time.
Usage
get_comment_time( $d, $gmt, $translate );
- $d(string)
- Time format. Format options see here.
Default: time format specified in settings - $gmt(boolean)
- Should the simple GMT date be used instead? A comment has 2 dates in the DB: server - comment_date, and adjusted for the site's country - comment_date_gmt.
Default: false - $translate(boolean)
- Should the time be translated (for feeds).
Default: true
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. |