Showing the date and time you last updated your WordPress post

Last updated on November 28, 2011. Tags: ,

In your WordPress-powered blog, the date (and sometimes the time) when the post is published is displayed in the post page (usually below the title) and in the list of posts within categories, tags, archive, home page and search results. This is the right thing to do because some information that are accurate today may no longer be accurate tomorrow,  next month or at anytime in the future.

However, in some cases, you might want to update an old post instead of writing an entirely new post. In that case, all you need to do is to inform your visitor when was the last time your post was updated. All you need to do is to insert the code below somewhere in the post template of your theme (single.php).

Last edited on <?php the_modified_date() ?>
at <?php the_modified_time()?>

You can change the "Last edited on" text to whatever you want.  The code <?php the_modified_date() ?> is the one that calls for the date the last time the post was updated and <?php the_modified_time() ?> for the hour and minute it was last updated. You might not need to include the time if you do not update your blog more than once in a day.

Using the code below will display the default format of date and time similar to the publish date.

Last edited on September 12, 2009 at 3:36 pm

You can format it in a way similar to the PHP codes calling for the publish date <?php the_date() ?> and time <?php the_time() ?>.

Last edited on <?php the_modified_date('m-d-y') ?>
at <?php the_modified_time('G:i')?>

The formatting above will change the display to something similar to the one below.

Last edited on 09-12-09 at 15:36

For more information about formatting time, check the following pages in WordPress codex:

Posted by Greten on September 25, 2009 under WordPress

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon
  • Technorati

Related Posts

You might also be interested (randomly generated):

Post Comments





Comment Rules and Reminders

  • The links to the commentator's e-mail do not have nofollow tag. However, I will be very strict in approving comments.
  • When you comment, please say something that indicates that you indeed read my post. If your comment is a general statement that can fit to any blog post about any topic, it will be regarded as spam.
  • What you write in the name field may include keywords to your website provided that (1) it's only up to four words long and (2) at least one of these four words is your first name or nickname. I rather reply to Bob or to Joe Smith than to Online Marketing Tips.
  • Please double check your comment before clicking the "Post" button. Once you clicked it, there will be no way for you to edit your comment.
  • Fields marked with asterisks (*) are required. Your email will never be displayed in public.