Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

get_post_datetime()

3 tags 1 category

get_post_datetime() — Retrieves 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.

Inputs: $post (int|WP_Post|null): Optional. Post ID or post object. Default is global $post object. $field (string): Optional. Published or modified time to use from database. Accepts ‘date’ or ‘modified’. Default ‘date’. $source (string): Optional. Local or UTC time to use from database. Accepts ‘local’ or ‘gmt’. Default ‘local’.

Returns DateTimeImmutable|false: Time object on success, false on failure.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…