Displays the time at which the post was last modified.
Parameters
$format
stringoptional- Format to use for retrieving the time the post was modified. Accepts
'G'
,'U'
, or PHP date format.
Defaults to the'time_format'
option.Default:
''
Source
function the_modified_time( $format = '' ) {
/**
* Filters the localized time a post was last modified, for display.
*
* @since 2.0.0
*
* @param string|false $get_the_modified_time The formatted time or false if no post is found.
* @param string $format Format to use for retrieving the time the post
* was modified. Accepts 'G', 'U', or PHP date format.
*/
echo apply_filters( 'the_modified_time', get_the_modified_time( $format ), $format );
}
Hooks
- apply_filters( ‘the_modified_time’,
string|false $get_the_modified_time ,string $format ) Filters the localized time a post was last modified, for display.
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |
Default Usage
Displays the time (date) the post was last modified, using the Default date format setting (e.g. F j, Y) from Administration > Settings > General.
Output is “Last modified: December 2, 2006”
Time in the 12-hour format (am/pm)
If a post was modified at 10:36pm, this example displays the time the post was last modified using the 12-hour format parameter string ‘g:i a’.
Output is “Time last modified: 10:36 pm”
Time in the 24-hour format
If a post was modified at 10:36pm, this example displays the time the post was last modified using the 24-hour format parameter string ‘G:i’.
Output is “Time last modified: 22:36”
Date as Month Day, Year
Displays the last modified time and date in the date format ‘F j, Y’ (ex: December 2, 2006), which could be used to replace the tag the_modified_date() .
Output is “Last modified: December 2, 2006”.
Date and Time
Displays the date and time.
Output is “Modified: December 2, 2006 at 10:36 pm”.