get_post_modified_time()
Gets the time when the post was modified. By default, it gets the Unix timestamp, but any format can be specified.
This function is used in other functions and is foundational. It is often better to use a wrapper function instead of this one.
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
Returns
String|Int|false. The date in the specified format or Unix timestamp if $id is 'U' or 'G'. False on failure.
Usage
get_post_modified_time( $d, $gmt, $post, $translate );
- $d(string)
- The format in which to get the date or time of the post modification. Possible formats.
Default: 'U' - $gmt(boolean)
- true - get GMT time, false - site time.
Default: false - $post(int/WP_Post)
- ID or object of the post whose modification time needs to be retrieved.
Default: null (current post) - $translate(boolean)
- Whether to translate the specified format. Strings like November, Saturday are translated.
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 Date in your language
If you need to get the date in the language specified in WP, set the parameter $translate = true:
get_post_modified_time( 'j \d\e F \d\e Y', false, null, true );
For Portuguese, this will be: 14 de novembro de 2019.
Changelog
| Since 2.0.0 | Introduced. |