Displays the date on which the post was last modified.
Parameters
$format
stringoptional- PHP date format. Defaults to the
'date_format'
option.Default:
''
$before
stringoptional- Output before the date.
Default:
''
$after
stringoptional- Output after the date.
Default:
''
$display
booloptional- Whether to echo the date or return it.
Default:
true
Source
function the_modified_date( $format = '', $before = '', $after = '', $display = true ) {
$the_modified_date = $before . get_the_modified_date( $format ) . $after;
/**
* Filters the date a post was last modified for display.
*
* @since 2.1.0
*
* @param string|false $the_modified_date The last modified date or false if no post is found.
* @param string $format PHP date format.
* @param string $before HTML output before the date.
* @param string $after HTML output after the date.
*/
$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $format, $before, $after );
if ( $display ) {
echo $the_modified_date;
} else {
return $the_modified_date;
}
}
Hooks
- apply_filters( ‘the_modified_date’,
string|false $the_modified_date ,string $format ,string $before ,string $after ) Filters the date a post was last modified for display.
Changelog
Version | Description |
---|---|
2.1.0 | Introduced. |
Default Usage
Displays the date the post was last modified, using the Default date format setting (e.g. F j, Y) from Administration > Settings > General.
Last modified: December 2, 2006
Date as Month Day, Year
Displays the last modified date in the date format ‘F j, Y’ (ex: December 2, 2006).
Last modified: December 2, 2006
Date and Time
Displays the date and time.
Modified: December 2, 2006 at 10:36 pm
Date with superscript or subscript number suffixes
Displays the date with a superscript or subscript st, nd, rd or th after the day. Because characters from the alphabet are used to represent the date format types, each of the HTML tag characters need to be escaped using a back slash. Superscript HTML tag is <sup> and subscript is <sub>.
Modified: 2nd Dec 2006