检索撰写帖子的时间。
原型
get_the_time( string $d = '', int|WP_Post $post = null )
参数
$d
(string)
(Optional)
用于检索帖子写入时间的格式。 “G”,“U”或php日期格式默认为time_format选项中指定的值。
$post
(int|WP_Post)
(Optional)
WP_Post对象或ID。默认为全局$ post对象。
返回值
(string|int|false)
格式化日期字符串或Unix时间戳if
源文件
路径:wp-includes/general-template.php
<?php
...
function get_the_time( $d = '', $post = null ) {
$post = get_post($post);
if ( ! $post ) {
return false;
}
if ( '' == $d )
$the_time = get_post_time(get_option('time_format'), false, $post, true);
else
$the_time = get_post_time($d, false, $post, true);
/**
* Filters the time a post was written.
*
* @since 1.5.0
*
* @param string $the_time The formatted time.
* @param string $d Format to use for retrieving the time the post was written.
* Accepts 'G', 'U', or php date format value specified
* in 'time_format' option. Default empty.
* @param int|WP_Post $post WP_Post object or ID.
*/
return apply_filters( 'get_the_time', $the_time, $d, $post );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_the_time/