Summery Summery
Retrieve the time at which the post was last modified.
Syntax Syntax
Parameters Parameters
- $format
-
(Optional) Format to use for retrieving the time the post was modified. Either 'G', 'U', or PHP date format defaults to the value specified in the time_format option.
Default value: ''
- $post
-
(Optional) Post ID or WP_Post object. Default current post.
Default value: null
Return Return
(string|false) Formatted date string or Unix timestamp. False on failure.
Source Source
File: wp-includes/general-template.php
$time = $datetime->format( $format ); } /** * Filters the localized time a post was written. * * @since 2.6.0 * * @param string $time The formatted time. * @param string $format Format to use for retrieving the time the post was written. * Accepts 'G', 'U', or PHP date format. Default 'U'. * @param bool $gmt Whether to retrieve the GMT time. Default false. */ return apply_filters( 'get_post_time', $time, $format, $gmt ); } /** * 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. *
Advertisement
Changelog Changelog
Version | Description |
---|---|
4.6.0 | Added the $post parameter. |
2.0.0 | Introduced. |