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, $echo );
- $format(string)
- PHP date format. option.
Default: 'date_format' - $before(string)
- Output before the date.
Default: '' - $after(string)
- Output after the date.
Default: '' - $echo(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. |