get_post_datetime


get_post_datetime ( $post = null, $field = 'date', $source = 'local' )

Parameters:
  • (int|WP_Post) post Optional. WP_Post object or ID. Default is global `$post` object.
  • (string) field Optional. Published or modified time to use from database. Accepts 'date' or 'modified'. Default 'date'.
  • (string) source Optional. Local or UTC time to use from database. Accepts 'local' or 'gmt'. Default 'local'.
Returns:
  • (DateTimeImmutable|bool) Time object on success, false on failure.
Defined at:

Description

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.

Related Functions

get_post_time, get_post_stati, get_post_modified_time, get_postdata, get_post_states

Top Google Results

User discussions

wpseek mobile