WordPress the_modified_date() Function

Beginner
6 min read
Updated: Nov 2026
3 examples
Prints the modified date

Definition

In WordPress, the_modified_date() prints the date a post was last edited. It is great for a line such as "Last updated on November 12, 2026".

Unlike the_date(), it prints every time you call it.

Syntax

A few ways to call the_modified_date().

WordPress
<p>Last updated: <?php the_modified_date( 'F j, Y' ); ?></p>
CallWhat it does
the_modified_date()Print the date in the site format.
the_modified_date( 'F j, Y' )Print the date in your own format.
the_modified_date( 'F j, Y', '<em>', '</em>' )Wrap the date in tags.
get_the_modified_date()Return the date as a string.

It prints the last modified date. The format letters are the same as the PHP date() function.

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

Parameters

ParameterDescription
$formatstring. A PHP date format. Default is the site date format.
$beforestring. Text or HTML before the date. Default is empty.
$afterstring. Text or HTML after the date. Default is empty.
$displaybool. true prints the date. false returns it. Default is true.

Return Value

Return ValueDescription
voidWhen $display is true, the date is printed.
stringWhen $display is false, the date is returned.

WordPress Examples

Three short examples. Each one shows the code and what it prints.

Example 1 — Last updated line

Print a simple updated date.

WordPress
<p>Last updated: <?php the_modified_date( 'F j, Y' ); ?></p>

How It Works

  1. the_modified_date() prints the date of the last edit.
  2. The format F j, Y gives a month name, day, and year.
  3. The text before is ours.

Example 2 — Wrap the date

Use the second and third arguments to add tags.

WordPress
<?php the_modified_date( 'F j, Y', '<em>Updated ', '</em>' ); ?>

How It Works

  1. The second argument is printed before the date.
  2. The third argument is printed after the date.
  3. No extra echo is needed.

Example 3 — Show only if changed

Print the updated line only if the post was edited on a later day.

WordPress
<?php
$published = get_the_date( 'Y-m-d' );
$modified  = get_the_modified_date( 'Y-m-d' );

if ( $modified !== $published ) {
  echo '<p>Updated on ' . esc_html( get_the_modified_date( 'F j, Y' ) ) . '</p>';
}

How It Works

  1. Both dates are returned as Y-m-d text.
  2. If the text is different, the post was edited later.
  3. Only then do we print the updated line.

Frequently Asked Questions

It prints the date when the post was last edited.
the_date() is for the publish date and prints once per day. the_modified_date() is for the last edit date and prints every time.
Use get_the_modified_date() or pass false as the fourth argument.
Pass a PHP date format as the first argument.
Use the_modified_time().

Browse all post functions

Open the functions index for simple guides with examples and FAQs.

Post Functions Index →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful