the_modified_date()
Display the date on which the post was last modified.
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
Return
String|null
. String if retrieving.
Usage
the_modified_date( $format, $before, $after, $display );
- $format(string)
- PHP date format. option.
Default: 'date_format' - $before(string)
- Output before the date.
Default: '' - $after(string)
- Output after the date.
Default: '' - $display(true|false)
- Whether to echo the date or return it.
Default: true
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.7.2
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; } }