the_modified_date()
Outputs the time (date) when the post was modified.
This function is identical to the function the_modified_time(), which also outputs the date/time of the post modification.
This Template Tag should be used inside the WordPress Loop.
Uses: get_the_modified_date()
1 time — 0.000555 sec (slow) | 50000 times — 1.86 sec (fast) | PHP 7.1.2, WP 4.7.3
Hooks from the function
Returns
String|null. Nothing when $echo = true. The date when the post was modified when $echo = false.
Usage
<?php the_modified_date( $format, $before, $after, $display ); ?>
- $format(string)
- The format in which the date will be displayed. Specify in the PHP accepted format (see here).
Default: format set in "Settings -> General" - $before(string)
- Text to be shown before the date.
Default: '' - $after(string)
- Text to be shown after the date.
Default: '' - $display(boolean)
- Display on screen (1) or return for processing into a variable (0).
Default: true (1)
Examples
#1 Display the date the post was last modified:
<p>Last modified: <?php the_modified_date(); ?></p>
Last modified: December 2, 2006
#2 Specify a custom format for the date of the last change:
<div>Last modified: <?php the_modified_date('j F Y'); ?></div>
Last modified: 25 April 2011
#3 Date and Time
Display the date and time the post was changed:
<p>Last modified: <?php the_modified_date('F j, Y \a\t G:i'); ?></p>
Last modified: December 2, 2006 at 1:36 p.m.
OR like so:
<p> <?php printf( __( 'Modified: %1$s at %2$s', 'textdomain' ), get_the_modified_date( 'F j, Y' ), get_the_modified_date( 'g:i a' ) ); ?> </p>
#4 Use HTML tags in format
To insert html tags into the format, you need escape symbols with \:
<p>Modified: <?php the_modified_date('j<\s\u\p>M</\s\u\p> Y'); ?
Modified: December 25Arp 2011
Changelog
| Since 2.1.0 | Introduced. |
the_modified_date() the modified date code WP 6.9.1
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 $the_modified_date The last modified date.
* @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;
}
}