the_modified_date( string $format = '', string $before = '', string $after = '', bool $display = true ): string|void

Displays the date on which the post was last modified.


Parameters

$format string Optional
PHP date format. Defaults to the 'date_format' option.

Default: ''

$before string Optional
Output before the date.

Default: ''

$after string Optional
Output after the date.

Default: ''

$display bool Optional
Whether to echo the date or return it.

Default: true


Top ↑

Return

string|void String if retrieving.


Top ↑

More Information

This tag works just like the_modified_time() , which also displays the time/date a post was last modified. This tag must be used within The Loop. If no format parameter is specified, the Default date format (please note that says Date format) setting from Administration > Settings > General is used for the display format.

If the post or page is not yet modified, the modified date is the same as the creation date.

Use get_the_modified_date() to retrieve the value.


Top ↑

Source

File: wp-includes/general-template.php. View all references

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;
	}

}

Top ↑

Hooks



Top ↑

Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Codex

    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.

    <p><?php printf( __( 'Last modified: %s', 'textdomain' ), get_the_modified_date() ); ?></p>

    Last modified: December 2, 2006

  2. Skip to note 4 content
    Contributed by Codex

    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>.

    <p><?php printf( __( 'Modified: %s', 'textdomain' ), get_the_modified_date('j\<\s\u\p\>S\<\/\s\u\p\> M Y') ); ?></p>

    Modified: 2nd Dec 2006

You must log in before being able to contribute a note or feedback.