函数原型
get_the_date( string $format = ”, int|WP_Post $post = null ): string|int|false
函数描述
Retrieves the date on which the post was written.
是否弃用
未弃用
函数参数
-
$format
string
Optional - PHP date format. Defaults to the
'date_format'option.Default:
'' -
$post
int|WP_Post
Optional - Post ID or WP_Post object. Default current post.
Default:
null
函数返回值
string|int|false Date the current post was written. False on failure.
函数位置
File: wp-includes/general-template.php.
函数源码
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 a post was published.
*
* @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 );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |

