WordPress函数:get_the_date
一、函数简介
检索帖子的日期。(Retrieves the date of the post.)二、函数参数
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option. * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post. * @return string|int|false Date the current post was written. False on failure.三、函数案例
<?php get_the_date( $format = '', $post = null ) ?>
四、源代码
/**
* Retrieves the date of the post.
*
* Unlike the_date() this function will always return the date.
* Modify output with the {@see 'get_the_date'} filter.
*
* @since 3.0.0
*
* @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
* @return string|int|false Date the current post was written. False on failure.
*/
function get_the_date( $format = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
$_format = ! empty( $format ) ? $format : get_option( 'date_format' );
$the_date = get_post_time( $_format, false, $post, true );
/**
* Filters the date of the post.
*
* @since 3.0.0
*
* @param string|int $the_date Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
* @param string $format PHP date format.
* @param WP_Post $post The post object.
*/
return apply_filters( 'get_the_date', $the_date, $format, $post );
}
THE END