the_modified_time() — WordPress Function

Usage, parameters, and examples for the WordPress function responsible to display the modified time (date) of posts and pages.

the_modified_time() is a WordPress function or tag that displays the last modified date and time of a post.

The function must be used within The Loop, and it does support a parameter to specify the format of Date and time. In case if no format parameter is assigned with the function, it will use the default date format as set on the General WordPress Settings.

If the page or post keep unmodified after the creation, the modified date and time returned by the_modified_time() will be remained the same as the creation time.

Usage and Parameters

<?php the_modified_time( $p ); ?>

…where $p is the only parameter the function supports. This parameter will help you to assign the format for the outputted modified date and time.

Please note that you should use this function with The Loop.

Example Usage


If you use the function without specifying the parameter it takes, it will automatically pick the date/time format set in the WordPress General Settings (WP Admin > Settings > General).

<p>Last modified: <?php the_modified_time(); ?></p>

Last modified: September 23, 2015

12-hour time format (am/pm)

Say the post was modified at 7:45pm, then the below example code will help displaying the modified time in 12-hour time format.

<p>Time last modified: <?php the_modified_time( 'g:i a' ); ?></p>

Time last modified: 7:45 pm

24-hour time format

If the post was modified at 7:45am, the below code helps showing the time in 24-hour time format.

<p>Time last modified: <?php the_modified_time('G:i'); ?></p>

Time last modified: 19:45

Just the modified date

If you want to display the last modified time in a date format (eg. September 23, 2015), the following code would be helpful:

<p>Modified: <?php the_modified_time( 'F j, Y' ); ?></p>

Last modified: September 23, 2015

Both Date and Time

The following code will help you to display both modified date and time together:

<p>Modified: <?php the_modified_time( 'F j, Y' ); ?> at <?php the_modified_time( 'g:i a' ); ?></p>

Modified: September 23, 2015 at 7:45 pm