Retrieves the comment date of the current comment.
$formatstringoptional
'date_format' option.Default:''
$comment_idint|WP_Commentoptional
The date format can be in a format specified in Formatting Date and Time
function get_comment_date( $format = '', $comment_id = 0 ) {
$comment = get_comment( $comment_id );
$_format = ! empty( $format ) ? $format : get_option( 'date_format' );
$comment_date = mysql2date( $_format, $comment->comment_date );
/**
* Filters the returned comment date.
*
* @since 1.5.0
*
* @param string|int $comment_date Formatted date string or Unix timestamp.
* @param string $format PHP date format.
* @param WP_Comment $comment The comment object.
*/
return apply_filters( 'get_comment_date', $comment_date, $format, $comment );
}
Filters the returned comment date.
| Version | Description |
|---|---|
| 4.4.0 | Added the ability for $comment_id to also accept a WP_Comment object. |
| 1.5.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_comment_date