get_comment_date

函数
get_comment_date ( $format = '', $comment_ID = 0 )
参数
  • (string) $format Optional. PHP date format. Defaults to the 'date_format' option.
    Required:
    Default: (empty)
  • (int|WP_Comment) $comment_ID WP_Comment or ID of the comment for which to get the date. Default current comment.
    Required:
返回值
  • (string) The comment's date.
定义位置
相关方法
get_commentdataget_comment_textget_comment_timeget_comment_typeget_comment_id
引入
1.5.0
弃用
-

get_comment_date – 这个函数返回评论发布的日期,根据WordPress管理员的日期和时间设置格式化。它接受评论的ID和可选的日期格式字符串作为参数。

检索当前评论的评论日期。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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 );
}

常见问题

FAQs
查看更多 >