• Skip to main content
  • Skip to primary sidebar
Making Different

Making Different

Create, Learn, Build or Fix

  • Tech
  • Business
  • Relationship
  • Health
  • Travel
You are here: Home / Web Development / WordPress / How to Show Last Modified Date in WordPress Posts and Pages

How to Show Last Modified Date in WordPress Posts and Pages

September 19, 2014 by Nitin Maheta

Displaying last update / modified date in WordPress posts and pages. If you are running a news or tutorial related blog on WordPress, And your article about the news or tutorial might be updated later. You must show the last modified date, so that your blog readers know if tutorial was updated or not. and for this, Today’s tutorial explains, how to display last update date in WordPress posts and pages.

To display last modified date in your WordPress posts and pages, all you have to do is to add a new function that will display the modified time. WordPress has a function the_time() which displays the published date. To enable modified date function, navigate to the functions.php file of your theme and then add the following code at the bottom :

Recommended for you:
How to Schedule Your Posts In WordPress

function md_the_time($format) {

$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');

echo the_time('F jS, Y');

if ($u_modified_time >= $u_time + 86400) {
echo " and last modified on ";
the_modified_time('F jS, Y');
}
}

The function is enabled, now it will display the publish date along with its modified date (if article was modified) as an example, if you have published an article on July 20, 2014 and 5 days later, you come to know that there is an update in the story, You can edit the article. and the function we added, it will show up the update date within its publish date like so “Published on July 20, 2014 and last modified on July 24, 2014.”

Now, If you would like to show the hour the article was update, Simply update the new function (above) to following :

function md_the_time($format) {

$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');

echo the_time('F jS, Y');

if ($u_modified_time >= $u_time + 86400) {
echo " and last modified on ";
the_modified_time('F jS, Y');
echo " at ";
the_modified_time();
echo ", ";
}
}

And now, We have to change time functions in the following pages:

  • single.php
  • index.php
  • page.php

So open them up and look for the following function:

the_time()
And replace it with this:
md_the_time()

I hope this tutorial help you to display last modified date in WordPress posts and page. If so, Don’t forget to share this tutorial with your blogger friends. :)



About Nitin Maheta

Nitin Maheta is editor in chief and webmaster of MakingDifferent Blog. You may reach him out on following social media:

Facebook | Twitter | Instagram

Primary Sidebar

Similar Posts

  • Gutenberg: An advanced WordPress editor for blog posting

Random Posts

10-Essential-Tips-for-a-Safe-Diwali

10 Essential Tips for a Safe Diwali

By Nitin Maheta

baby-shower

Thank You Messages for Baby Shower Messages and Gifts

By Nitin Maheta

Different-ways-to-greet-someone

Different Ways to Greet Someone

By Nitin Maheta

baby-birth-announcement-wordings

Baby Birth Announcement Wordings

By Nitin Maheta

spying

How to Spy on your NonTechie Lover

By Nitin Maheta

All categories | About us | Contact us | Privacy policy | Disclaimer | Write for Us | Dictionary | Sitemap

The owner of this site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.

© 2025 Making Different