In the WordPress Codex, the online manual for WordPress Users, there is an article that will help you set the date and time, so to speak, for your WordPress blog, called Formatting Date and Time, using the PHP codes for the time and date.
Using a combination of WordPress Template Tags and PHP codes for date and time, you can let your readers known when you published your blog post in a variety of ways.
For instance, in the post meta data, you can set the time and time to a format of your choosing, based upon international and cultural time formats, or one of your choosing.
Examples of the various formats for time and dates include:
l, F j, Y- Friday, September 24, 2007m/j/y g:i A- 05/12/07 9:35 AM1, j F Y- Monday, 21 February 2007Y- 2007j F Y- 20 April 2007
You can spread out the date information in your post meta data section in the form of a sentence:
This post was written on the
<?php the_time('jS'); ?> day in the month
of <?php the_time('F'); ?> in the year of
<?php the_time('Y'); ?>
Which would result in:
This post was written on the 15th
day in the month of February in the year of 2007
Display the Date the Post was Modified or Updated
As of WordPress version 2.1, you can now showcase the date your blog post was modified, not just published. The the_modified_date template tag displays the date the post was last modified, and the_modified_time() displays the last modified time. These work only when used within the WordPress Loop, the code that generates the post content information.
Published <?php the_date('F j, Y'); ?>
Modified <?php the_modified_date(); ?>
Displays:
Published August 1, 2004
Modified April 23, 2007
This is helpful for articles which require updates, or for helping update your readers so they know when the blog post was last updated.
The article on the WordPress Codex, Designing the WordPress Post Meta Data Section, covers a lot of ways to use dates and times in that section.
You can find more variations on using the date and time in the the_date and the_time() WordPress Template Tags, but let’s take this a little further.
Adding the Date and Time To Your Byline
The date and/or time can be incorporated into the byline under the post title, in the post meta data section, or elsewhere in your blog.
For example, your byline can read:
By <?php the_author(); ?> on <?php the_date('F j, Y'); ?>
Would display the author’s name as set in the Administration Panels under Profile with the date:
By Fred Smith on August 31, 2007
Let’s look at another practical use for your WordPress Blog: on your copyright statement.
Copyright Date
While most copyright statements don’t need the date, in some countries, the date should be included in the copyright statement. Many bloggers manually code this date in their copyright statement, but what happens next year? Why not use the PHP date commands to recreate a constantly updating year on the copyright statement?
Using the PHP date commands, you can set your copyright statement to automatically update every January, when the current year changes:
In your footer.php, single.php, or index.php template file, wherever you choose to display your copyright statement, add the following:
Copyright © <?php the_time('Y') ?> <?php bloginfo('name'); ?>
This will display:
Copyright © 2007 Lorelle on WordPress
If you want your name instead of the blog’s title, remove the WordPress Template tag for automatically displaying your blog’s name and type in the name you wish to use. I recommend you include links around the copyright to your copyright policy, and around your name to your blog, to help you track any incoming links from those who may be violating your copyright. This works best when used in the post content area on the single.php or index.php template files.
<a href="http://example.com/Copyright_Policy/" title="Copyright Policy">Copyright
© <?php the_time('Y') ?></a>
<a href="http://example.com/" title="My Blog Example">Fred Smith</a>
Results in:
Copyright © 2007 Fred Smith
Copyrights can cross years, so why not modify the copyright date section to include the original starting date of your blog to the current year?
Copyright © 2000 -<?php the_time('Y') ?>
Copyright © 2000-2007 Fred Smith
Have you come up with some other tips and tricks for using the PHP date and time codes within your WordPress blogs?
Related Articles
- Table Of Date Format Characters On The PHP Website
- Showing Dates Not Just Times in Your Multi-Post Views
- Do You Update Posts or Post Updates?
- Showing Dates Not Just Times in Your Multi-Post Views
- Post Meta Data WordPress Plugins
- WordPress Category Feed Links in Your Post Meta Data Section


Site Search Tags: wordpress tips, dates, time, date, wordpress template tags, template tags, date template tags, time template tags, date tags, time tags, post meta data, byline, copyright, wordpress themes, template files
Subscribe
Via Feedburner
Subscribe by Email
Copyright Lorelle VanFossen, member of the 9Rules Network, and author of Blogging Tips, What Bloggers Won't Tell You About Blogging.













18 Comments
Lorelle,
Great post!!!
Is there a easy way to only display the last modified date if it applies?
I would like to have nothing there unless the post has ever been modified.
There may be an easier way to do this, but I would match the original date against the modified date and if they were different, post the modified date. I tested this out on my blog, so it should work for you!
Modified: < ?php $origdate = get_the_time();$moddate = get_the_modified_time();
if ($origdate != $moddate){ the_modified_date();} ?>
If the above code doesn’t display, I also reposted it here
The link above goes to a 404 Page Not Found, Jenn. And it looks like you need a few lessons on Writing and Publishing Code in Your WordPress Blog Posts, which applies to comments, too.
Turn those < into < for a start.
Thanks for the try. You are saving me from looking this up.
aaahhhhh great informative post, thanks
Bookmarked and will use for future reference
Ahh alas. My braindead self managed to move the page for organizational purposes after I posted the link! Sorry about that! The code lives here now if you’re still looking, Kyle!
Now off to brush up on “Writing and Publishing Code in your WordPress Blog Posts”. Thanks Lorelle! Glad you’re back to posting!
I cleaned it up for posting and added it to your comment above, Jenn. Thanks so much. I use a WordPress Plugin to do this on my main blog, which doesn’t work in the latest version of WordPress, so I’m going to try this. THANK YOU!
Any way to abbreviate the month? It won’t fit in my little date box…
Found my own answer:
http://us2.php.net/date
In what files does this need to be placed?
Published
Modified
Thanks.
June
This is great. I have no experience in coding. And I was getting used to the theme I had chosen (which is a modified version of the NT-greeny theme). But this theme has no option for displaying the dates.
This had been bothering me for a while. I read through other tutorials for this, but for a novice like me, it was difficult to follow through…
But this post was great!! I was able to implement the date. AND it also showed links and sections for more experienced coders.
I am having some layout issues, which I should get sorted somehow. I don’t know what I messed up, but it isn’t too serious. In any case, the date finally displays. Hurrah!

@ Hammy:
Designing a web page is like playing with dominoes. For every small change, there is an equal, and usually opposite and unwanted change.
Lorelle,
Thanks for the post, but I am not sure the following is correct, you write:
“Why not use the PHP date commands to recreate a constantly updating year on the copyright statement?
Using the PHP date commands, you can set your copyright statement to automatically update every January, when the current year changes:”
And you suggest this code:
“Copyright © … ”
When I tried that I kept getting the post year, not the current year, which is what I wanted for the copyright statement. To always get the current year, this works:
Copyright ©
Ok, one more time:
Copyright © php echo date(’Y');
as opposed to:
Copyright © php the_time(’Y');
(I’m leaving off the php start and end markers so the important part displays.)
There are WordPress Template tags for handling the date, and PHP commands. That’s the difference. Yes, one creates a static date, but the one at the end of my article dealing with copyright changes with the actual year, not a fixed date, which is the intention of that usage. Does that answer your question?
To write code in blog posts and comments, see Writing and Publishing Code in Your WordPress Blog Posts.
Would it be possible to show date and time in another language? I have an Italian blog, and date and time show up in English.
thank you.
@ francesco:
If your WordPress Theme has been set up for localization, check out WordPress in Your Language in the WordPress Codex for information on how to do this, and support, in your language.
Hi all!
I just discovered that even though my date settings seems to be right, the leading zero is missing when the date is 1 to 9. Not sure where and how to add it. Date format for Sweden is
2008-07-07 (july 7, 2008) or 2008-11-21 (November 11, 2008).
Where should I add that missing zero, so it only shows when the day or month is between 1 and 9?
@ Niklas Wikman:
I’m not sure I understand your issue as it looks right to me. If you are looking for July 07, 2008, that’s not a traditional date format. That will have to be manually changed. See Formatting Date and Time. I also do not understand where you are finding this date, within the Administration Panels, in the post meta data section of your blog post, or what, but I’m sure you have reported it in the WordPress Support Forum and the WordPress Bug Report so people can investigate this further.
4 Trackbacks/Pingbacks
[...] Cómo visualizar la fecha en un theme de WP [...]
[...] posts about Displaying the Date in Your WordPress Theme. A useful post about different styles of showing the date, using it for copyright date and in the [...]
[...] Displaying the Date in Your WordPress Theme: The time and date plays an important role in your WordPress Theme. In the byline or post meta section, it tells readers when the post was published. It can also be used elsewhere to provide chronological or date information about your blog and blog post with these tips. [...]
[...] Lorelle put the_time(); too, so I guess I might as well leave it like that. Tagged with: 2008 • [...]
Post a Comment