get_post_modified_time()
Retrieve the time at which the post was last modified.
Uses: mysql2date()
1 time — 0.00003 sec (very fast) | 50000 times — 0.34 sec (very fast) | PHP 7.0.8, WP 4.6.1
Hooks from the function
Return
String|Int|false
. Formatted date string or Unix timestamp if $format is 'U' or 'G'. False on failure.
Usage
get_post_modified_time( $format, $gmt, $post, $translate );
- $format(string)
- Format to use for retrieving the time the post was modified. Accepts 'G', 'U', or PHP date format.
Default: 'U' - $gmt(true|false)
- Whether to retrieve the GMT time.
Default: false - $post(int|WP_Post)
- Post ID or post object.
Default: global $post object - $translate(true|false)
- Whether to translate the time string.
Default: false
Examples
#1 Examples showing what the function outputs
echo get_post_modified_time(); //> 1472693996 echo get_post_modified_time( 'j M Y' ); //> 1 Sep 2016 echo get_post_modified_time( 'j\ M Y', 0, null, $translate = true ); //> 1 Sep 2016 echo get_post_modified_time( 'H:i:s' ); //> 01:39:56
#2 Get the date on your own language
If you would like to get the date on your own language defined in WP, just set the parameter $translate = true:
get_post_modified_time( 'j \d\e F \d\e Y', false, null, true );
For portuguese, it will return: 14 de novembro de 2019
.
Changelog
Since 2.0.0 | Introduced. |