检索上次修改帖子的时间。
原型
get_post_modified_time( string $d = 'U', bool $gmt = false, int|WP_Post $post = null, bool $translate = false )
参数
$d
(string)
(Optional)
用于检索帖子修改时间的格式。 ‘G’,‘U’或php日期格式。
$gmt
(bool)
(Optional)
是否检索GMT时间。
$post
(int|WP_Post)
(Optional)
WP_Post对象或ID。默认为全局$ post对象。
$translate
(bool)
(Optional)
是否翻译时间字符串。
返回值
(string|int|false)
格式化日期字符串或Unix时间戳if
源文件
路径:wp-includes/general-template.php
<?php
...
function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
$post = get_post($post);
if ( ! $post ) {
return false;
}
if ( $gmt )
$time = $post->post_modified_gmt;
else
$time = $post->post_modified;
$time = mysql2date($d, $time, $translate);
/**
* Filters the localized time a post was last modified.
*
* @since 2.8.0
*
* @param string $time The formatted time.
* @param string $d The date format. Accepts 'G', 'U', or php date format. Default 'U'.
* @param bool $gmt Whether to return the GMT time. Default false.
*/
return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_post_modified_time/