Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
get_post_datetime() - 以DateTimeImmutable对象实例检索文章发布或修改的时间 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / get_post_datetime()

get_post_datetime( int|WP_Post $post = null, string $field = 'date', string $source = 'local' )

以DateTimeImmutable对象实例检索文章发布或修改的时间


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 3 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "ba711e0e74d730faa4dec8cb551b7f71" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "c662a3ca6b84e8f01cc3765430bbe052" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

postmore...


描述

该对象将根据WordPress设置设置为时区。

由于传统原因,此函数允许选择从数据库中的本地时间或UTC时间实例化。通常,这对结果没有影响。然而,这些值在数据库中可能会不同步,这通常是因为时区设置发生了更改。该参数确保在这种情况下能够再现向后兼容的行为。


参数

$post

(int|WP_Post) (可选) WP_Post对象或ID。默认值为全局$post对象。

默认值: null

$field

(string) (可选) 使用数据库的发布或修改时间。接受“date”或“modified”。

默认值: 'date'

$source

(string) (可选) 使用数据库的本地或UTC时间。接受“local”或“gmt”。

默认值: 'local'


返回

(DateTimeImmutable|false) 成功时为时间对象,失败时为false。



源码

查看源码 官方文档


更新日志

版本描述
5.3.0开始引入

Warning: Undefined variable $o in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference.php on line 194