WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/the modified date

Description

This tag displays the date (and time) a post was last modified. 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.

Usage

 <?php the_modified_date$d$before$after$echo ); ?> 

Parameters

$d
(string) (optional) The format the date is to display in. Defaults to the date format configured in your WordPress settings. See Formatting Date and Time.
Default: date format specified in Administration > Settings > General
$before
(string) (optional) Output before the date.
Default: None
$after
(string) (optional) Output after the date.
Default: None
$echo
(boolean) (optional) Default is display. Whether to echo the date or return it.
Default: true
  • true (default)
  • false

Examples

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>Last modified: <?php the_modified_date(); ?></p>
Last modified: December 2, 2006

Date as Month Day, Year

Displays the last modified date in the date format 'F j, Y' (ex: December 2, 2006).

<div>Last modified: <?php the_modified_date('F j, Y'); ?></div>
Last modified: December 2, 2006

Date and Time

Displays the date and time.

<p>Modified: <?php the_modified_date('F j, Y'); ?> at <?php the_modified_date('g:i a'); ?></p>
Modified: December 2, 2006 at 10:36 pm

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>Modified: <?php the_modified_date('j\<\s\u\p\>S\<\/\s\u\p\> M Y'); ?></p>
Modified: 2nd Dec 2006

Changelog

  • 3.0.0: Added $before, $after and $echo parameters
  • Since: 2.1.0

Source File

the_modified_date() is located in wp-includes/general-template.php.

Related

get_calendar(), get_day_link(), get_month_link(), get_the_date(), get_the_time(), get_year_link(), single_month_title(), the_date(), the_date_xml(), the_modified_date(), get_the_modified_date(), the_modified_time(), get_the_modified_time(), the_time()

See also index of Function Reference and index of Template Tags.