On this page
get_comment_date( string $format = '', int|WP_Comment $comment_ID ): string
Retrieves the comment date of the current comment.
Parameters
$formatstring Optional-
PHP date format. Defaults to the
'date_format'option.Default:
'' $comment_IDint|WP_Comment Optional-
WP_Comment or ID of the comment for which to get the date.
Default current comment.
Return
string The comment's date.
More Information
The date format can be in a format specified in Formatting Date and Time
Source
File: wp-includes/comment-template.php. View all references
function get_comment_date( $format = '', $comment_ID = 0 ) {
$comment = get_comment( $comment_ID );
$_format = ! empty( $format ) ? $format : get_option( 'date_format' );
$date = mysql2date( $_format, $comment->comment_date );
/**
* Filters the returned comment date.
*
* @since 1.5.0
*
* @param string|int $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', $date, $format, $comment );
}
Hooks
- apply_filters( 'get_comment_date',
string|int $date ,string $format ,WP_Comment $comment ) -
Filters the returned comment date.
Related
Uses
| Uses | Description |
|---|---|
| mysql2date() wp-includes/functions.php | Converts given MySQL date string into a different format. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
| get_comment() wp-includes/comment.php | Retrieves comment data given a comment ID or comment object. |
Used By
| Used By | Description |
|---|---|
| WP_Comments_List_Table::column_date() wp-admin/includes/class-wp-comments-list-table.php | |
| Walker_Comment::comment() wp-includes/class-walker-comment.php | Outputs a single comment. |
| Walker_Comment::html5_comment() wp-includes/class-walker-comment.php | Outputs a comment in the HTML5 format. |
| comment_date() wp-includes/comment-template.php | Displays the comment date of the current comment. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Added the ability for $comment_ID to also accept a WP_Comment object. |
| 1.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_comment_date