函数原型
get_comment_date( string $format = ”, int|WP_Comment $comment_ID ): string
函数描述
Retrieves the comment date of the current comment.
是否弃用
未弃用
函数参数
-
$format
string
Optional - PHP date format. Defaults to the
'date_format'option.Default:
'' -
$comment_ID
int|WP_Comment
Optional - WP_Comment or ID of the comment for which to get the date.
Default current comment.
函数返回值
string The comment’s date.
函数位置
File: wp-includes/comment-template.php.
函数源码
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 );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 4.4.0 | Added the ability for $comment_ID to also accept a WP_Comment object. |
| 1.5.0 | Introduced. |

