get_comment_time

函式
get_comment_time ( $format = '', $gmt = false, $translate = true )
引數
  • (string) $format Optional. PHP time format. Defaults to the 'time_format' option.
    Required:
    Default: (empty)
  • (bool) $gmt Optional. Whether to use the GMT date. Default false.
    Required:
    Default: false
  • (bool) $translate Optional. Whether to translate the time (for use in feeds). Default true.
    Required:
    Default: true
返回值
  • (string) The formatted time.
定義位置
相關方法
get_comment_metaget_comment_dateget_comment_textget_comment_typeget_comment_id
引入
1.5.0
棄用
-

get_comment_time – 這個函式返回評論釋出的時間,根據WordPress管理中的日期和時間設定格式化。它接收評論ID和可選的時間格式字串作為引數。

檢索當前評論的評論時間。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_comment_time( $format = '', $gmt = false, $translate = true ) {
$comment = get_comment();
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
$_format = ! empty( $format ) ? $format : get_option( 'time_format' );
$date = mysql2date( $_format, $comment_date, $translate );
/**
* Filters the returned comment time.
*
* @since 1.5.0
*
* @param string|int $date The comment time, formatted as a date string or Unix timestamp.
* @param string $format PHP date format.
* @param bool $gmt Whether the GMT date is in use.
* @param bool $translate Whether the time is translated.
* @param WP_Comment $comment The comment object.
*/
return apply_filters( 'get_comment_time', $date, $format, $gmt, $translate, $comment );
}
function get_comment_time( $format = '', $gmt = false, $translate = true ) { $comment = get_comment(); $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; $_format = ! empty( $format ) ? $format : get_option( 'time_format' ); $date = mysql2date( $_format, $comment_date, $translate ); /** * Filters the returned comment time. * * @since 1.5.0 * * @param string|int $date The comment time, formatted as a date string or Unix timestamp. * @param string $format PHP date format. * @param bool $gmt Whether the GMT date is in use. * @param bool $translate Whether the time is translated. * @param WP_Comment $comment The comment object. */ return apply_filters( 'get_comment_time', $date, $format, $gmt, $translate, $comment ); }
function get_comment_time( $format = '', $gmt = false, $translate = true ) {
	$comment = get_comment();

	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;

	$_format = ! empty( $format ) ? $format : get_option( 'time_format' );

	$date = mysql2date( $_format, $comment_date, $translate );

	/**
	 * Filters the returned comment time.
	 *
	 * @since 1.5.0
	 *
	 * @param string|int $date      The comment time, formatted as a date string or Unix timestamp.
	 * @param string     $format    PHP date format.
	 * @param bool       $gmt       Whether the GMT date is in use.
	 * @param bool       $translate Whether the time is translated.
	 * @param WP_Comment $comment   The comment object.
	 */
	return apply_filters( 'get_comment_time', $date, $format, $gmt, $translate, $comment );
}

常見問題

FAQs
檢視更多 >