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
檢視更多 >