WordPress the_modified_date() Function

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().
<p>Last updated: <?php the_modified_date( 'F j, Y' ); ?></p>
| Call | What 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
the_modified_date( string $format = '', string $before = '', string $after = '', bool $display = true ): string|void
Parameters
| Parameter | Description |
|---|
$format | string. A PHP date format. Default is the site date format. |
$before | string. Text or HTML before the date. Default is empty. |
$after | string. Text or HTML after the date. Default is empty. |
$display | bool. true prints the date. false returns it. Default is true. |
Return Value
| Return Value | Description |
|---|
| void | When $display is true, the date is printed. |
| string | When $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.
<p>Last updated: <?php the_modified_date( 'F j, Y' ); ?></p>
<p>Last updated: November 12, 2026</p>
How It Works
the_modified_date() prints the date of the last edit.- The format
F j, Y gives a month name, day, and year. - The text before is ours.
Example 2 — Wrap the date
Use the second and third arguments to add tags.
<?php the_modified_date( 'F j, Y', '<em>Updated ', '</em>' ); ?>
<em>Updated November 12, 2026</em>
How It Works
- The second argument is printed before the date.
- The third argument is printed after the date.
- 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.
<?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>';
}
<p>Updated on November 12, 2026</p>
How It Works
- Both dates are returned as
Y-m-d text. - If the text is different, the post was edited later.
- 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
Developer, cloud engineer, and technical writer
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