the_modified_date() WordPress Function

The the_modified_date() function is a Wordpress function that outputs the date on which the current post was last modified.

the_modified_date( string $format = '', string $before = '', string $after = '', bool $echo = true ) #

Display the date on which the post was last modified.


Parameters

$format

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

Default value: ''

$before

(string)(Optional) Output before the date.

Default value: ''

$after

(string)(Optional) Output after the date.

Default value: ''

$echo

(bool)(Optional) Whether to echo the date or return it.

Default value: 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

function the_modified_date( $format = '', $before = '', $after = '', $echo = 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 ( $echo ) {
		echo $the_modified_date;
	} else {
		return $the_modified_date;
	}

}


Top ↑

Changelog

Changelog
VersionDescription
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More