get_post_modified_time( string $format = 'U', bool $gmt = false, int|WP_Post $post = null, bool $translate = false )
Retrieves the time at which the post was last modified.
Parameters
- $format
-
(Optional) Format to use for retrieving the time the post was modified. Accepts 'G', 'U', or PHP date format. Default 'U'.
Default value: 'U'
- $gmt
-
(Optional) Whether to retrieve the GMT time.
Default value: false
- $post
-
(Optional) Post ID or post object. Default is global
$post
object.Default value: null
- $translate
-
(Optional) Whether to translate the time string.
Default value: false
Return
(string|int|false) Formatted date string or Unix timestamp if $format
is 'U' or 'G'.<br> False on failure.
Source
File: wp-includes/general-template.php
function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
$post = get_post($post);
if ( ! $post ) {
return false;
}
if ( $gmt )
$time = $post->post_modified_gmt;
else
$time = $post->post_modified;
$time = mysql2date($d, $time, $translate);
/**
* Filters the localized time a post was last modified.
*
* @since WP-2.8.0
*
* @param string $time The formatted time.
* @param string $d The date format. Accepts 'G', 'U', or php date format. Default 'U'.
* @param bool $gmt Whether to return the GMT time. Default false.
*/
return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
}
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |