首页 WordPress函数大全 get_post_datetime()

get_post_datetime()

2020-05-01 / 4794阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

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

Retrieve post published or modified time as a DateTimeImmutable object instance.

描述

The object will be set to the timezone from WordPress settings.

For legacy reasons, this function allows to choose to instantiate from local or UTC time in database. Normally this should make no difference to the result. However, the values might get out of sync in database, typically because of timezone setting changes. The parameter ensures the ability to reproduce backwards compatible behaviors in such cases.

参数

$post

(int|WP_Post)
(Optional)
WP_Post object or ID. Default is global $post object.

Default value: null

$field

(string)
(Optional)
Published or modified time to use from database. Accepts 'date' or 'modified'.

Default value: 'date'

$source

(string)
(Optional)
Local or UTC time to use from database. Accepts 'local' or 'gmt'.

Default value: 'local'

返回

(DateTimeImmutable|false) Time object on success, false on failure.

大家谈论
    我的见解