comment_date()
Outputs the publication date of the comment. You can specify the desired format.
Uses: get_comment_date()
No Hooks.
Returns
null
.
Usage
<?php comment_date( $d, $comment_ID ); ?>
- $d(string)
- Date format. All possible formats.
Default: date format set in WordPress settings - $comment_ID(int/object)
- ID or object of the comment whose publication date you want to retrieve.
Default: ID of the current comment
Examples
#1 Display the date of the current comment in desired format:
Comment date: <?php comment_date( 'n-j-Y' ); ?>
Displays: Comment date: 12-6-2011
.
Changelog
Since 0.71 | Introduced. |
Since 4.4.0 | Added the ability for $comment_id to also accept a WP_Comment object. |
comment_date() comment date code WP 6.8.1
function comment_date( $format = '', $comment_id = 0 ) { echo get_comment_date( $format, $comment_id ); }