Last updated on November 28, 2011. Tags: date and time, updating post
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
Comment Rules and Reminders