ThemeLib
  • Home
  • Blogger
    • Blogger Templates
    • Blogger Widgets
    • Blogger Tutorials
  • Wordpress
    • Wordpress Themes
    • Wordpress Plugins
    • Wordpress Tutorials
    • Special Offers
  • Special Offers
  • About
  • Contact
  • Advertise
September 14th, 2008 # Wordpress Tutorials #

The Ultimate Guide to WordPress Date and Time

In this tutorial, I’ll be going over The Date and The Time, and how can you use it to display your posts information. Hopefully you will find this ultimate guide easier to understand and follow than what’s available in the WordPress documentation.

The Date and Time format string

  • l = Full name for day of the week (lower-case L).
  • F = Full name for the month.
  • j = The day of the month.
  • S = The English suffix for the day of the month (e.g st, nd or th in the 1st, 2nd or 15th.)
  • Y = The year in 4 digits. (lower-case y gives the year’s last 2 digits)

Here are examples of the various formats for date and time:

  • l, F j, Y – Friday, March 5, 2009
  • m/j/y g:i A – 05/12/09 7:30 AM
  • j F Y – 25 May 2009
  • Y – 2009

Adding the Date and the Time to your posts

You can display your post information in the post meta data section in the form of a sentence:

This entry was posted on <?php the_time('l, F jS, Y') ?> at <?php the_time('g:i a'); ?> and is filed under <?php the_category(', ') ?>

The result should be something like this :
This entry was posted on 15 August 2008 at 12:41 am and is filed under Wordpress Tutorials.

Note: Even though we can use the_date() tag to display your post date, it is highly not recommended because when there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()).

Display the Date and the Time your post was modified

The the_modified_date template tag displays the date your post was last modified, and the_modified_time() displays the last modified time. Note that these only work when used within the WordPress Loop, the code that generates your post content information.

Code :

This post was published on <?php the_date('F j, Y'); ?> and was last modified on <?php the_modified_date(); ?> at <?php the_modified_time() ?>

Result :
This post was published on July 4, 2008 and was last modified on December 13, 2009 at 7:30 am

This is helpful for helping update your readers so they know when your blog post was last updated. 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.

Copyright Date

As you know, most copyright statements don’t need the full date, we only need the year. Many bloggers hard-code the year in their copyright statement (me too :D ). In my opinion, it is fine because it is not required us update regularly, just one per year. In fact we could 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 year

In your footer.php template file add the following code :
Copyright © <?php the_time('Y'); ?> <?php bloginfo('name'); ?>

This will display:
Copyright © 2009 ThemeLib

Conclusion

So now you (hopefully) have a better insight on the Wordpress Date and Time. Feel free to leave a comment if you liked it, hated it, couldn’t understand, whatever – I welcome all feedback. Do not forget to subscribe to my feed for all the latest updates on ThemeLib theme releases and new tutorials. Thanks for reading.

P/s: I “stole” the article title of the post The Ultimate Guide to the WordPress Loop on ThemeLab :oops:

  • Tweet This!
  • Digg this!
  • Share this on del.icio.us
  • Stumble upon something good? Share it on StumbleUpon
  • Share this on Technorati
  • Share this on Reddit
  • Email this to a friend?
  • Subscribe to the comments for this post?

Did you miss any of these related posts?

  • Wordpress 2.8 Is Available!
  • Wordpress 2.8 Beta 1 Is Out
  • WordPress 2.7.1 Released
  • WordPress 2.7 Release Candidate 1
  • Wordpress 2.7 Project Icons – Vote Now!

11 Responses to "The Ultimate Guide to WordPress Date and Time"

  1. artikel pendidikan indonesia says:
    September 14, 2008 at 10:23 PM

    nice tutorial. thanks

    Reply
  2. artikel pendidikan indonesia says:
    September 16, 2008 at 4:25 AM

    hey, i saw a very simple but cool template today. it is VERYPLAINTXT wordpress template by SCOTT WALLICK. You can see the demo here
    would you please convert it to blogger? i’ll wait

    Reply
  3. Nihar says:
    September 25, 2008 at 8:53 AM

    Nice post showing all the options. i can now play around with the date formats and modify my index.php file.

    Thanks,
    Nihar

    Reply
  4. Samantha says:
    October 5, 2008 at 10:59 AM

    I use very little the date and time features of WP – usually keeping the default settings-but this tutorial is complete
    cheers

    Reply
  5. Arun Basil Lal says:
    December 15, 2008 at 3:07 PM

    Hey,
    i have a question,
    Using the code for the example “This post was published on July 4, 2008 and was last modified on December 13, 2009 at 7:30 am” will display was modified on even if the post was not modified..rgiht..?

    I mean, was modified on will be there even if the modified date returns null of the same date.
    I think the following code can fix thies:
    Posted on <?php $u_modified_time = get_the_modified_time('U');
    if ($u_modified_time != $u_time) {
    echo "and last modified on ";
    the_modified_time('F jS, Y');
    echo ". "; } ?>

    Thanks. Cheers..

    Reply
    • nhc says:
      December 15, 2008 at 6:02 PM

      When posting code, remember to convert all < character to “& l t ;” (without spaces) ;)

      Reply
  6. Atniz says:
    January 23, 2009 at 5:03 AM

    I have never heard about Copyright date. Thanks for sharing this info.

    Reply
  7. Ali Hussain says:
    February 10, 2009 at 2:35 PM

    I like what you have posted, but a better tutorial could be found at wordpress.org

    Reply
  8. Aryeh says:
    April 27, 2009 at 5:34 PM

    How do I add the current date and time to the header?

    Reply
  9. bobby says:
    June 5, 2009 at 9:11 PM

    Very nice tutorial. I appreciate your work and time in laying this out for us.

    Reply
  10. Plaveb says:
    June 10, 2009 at 4:52 AM

    hey, this is very handy and useful tutorial, I have tried few techniques given in this tutorial and all are working fine for me.
    thanks for sharing

    Reply

Leave a comment

Click here to cancel reply.

Comments guidelines: If you drop SEO comments (ie "My Cool Online Shop" instead of "Michael"), I will remove your links! Use your name when leaving comments!

RSS feed

Feedburner RSS feed
Most articles on this site are related to blogger templates, wordpress themes, blog design, tips, tricks, and plenty of fun :)

Grab the feed or enter your email address to get the party started! It is FREE.

Search our archives

Categories

  • Advertising Networks
  • Affiliate Marketing
  • Blogger Templates
  • Blogger Tutorials
  • Blogger Widgets
  • Blogging Tips
  • Blogosphere
  • Personal
  • Reviews
  • Search Engines
  • Site News
  • Web Stuff
  • Wordpress News
  • Wordpress Plugins
  • Wordpress Themes
  • Wordpress Tutorials

Top Commenters

  • Lindagr (6)
  • Web Hosting Service (6)
  • Jacques Snyman (5)
  • Yogindernath (5)
  • Ali Hussain (4)

Entrecard Blog

More Resources

  • Domain Name Registration
  • Web Templates
  • Cheap Hosting
  • Unlock iPhone 2.2.1
  • Dataflurry Seo Services
  • TV on PC
  • Web Hosting Reviews
  • Apple Iphone
  • Unlock iPhone 3G
  • HD Wallpapers
  • UK Web Hosting
  • Web Hosting
  • Your link here →

Recent Posts

    • bbPress 1.0 Final Is Available
    • Feature Pitch Premium Wordpress Theme by WooThemes
    • Internal Linking and Search Engine Optimization
    • ePhoto Premium Wordpress Theme by Elegant Themes
    • WooThemes 4-for-1 Special Offer
    • Comparing Mobile Broadband Providers and Broadband Deals at Broadband-Expert
    • Why You Might Not Be Seeing Desired Earnings
    • Wordpress 2.8 Is Available!
    • Getting Started with Search Engine Optimization – Part 4
    • Education Premium Wordpress Theme by StudioPress

Popular Posts

    • Arthemia magazine blogger template (486)
    • Google PageRank update September 2008 - My blog got PR5 (150)
    • Maggo magazine blogger template (106)
    • Google Pagerank Update December 2008 - ThemeLib is now PR6! (105)
    • Personal Mag magazine blogger template (100)
    • White Space blogger template (93)
    • ThemeLib Giveaway Free Memberships to Elegant Themes for Three Subscribers (87)
    • Astro colorful blogger template (83)
    • Link love to Top Commentators :) (80)
    • Photobucket Bandwidth Exceeded! I Need Your Help! (74)

Recent Comments

    • Haigo Hein:This SEO stuff is so hard, I am still so dumb in this area:...
    • Affiloblueprint success:Are there adsense units in the html template? Thanks I implemented this already...
    • Jacques Snyman:Angie, that is my stance too. WordPress is KING, but I see that WooThemes have ...
    • Jacques Snyman:It does look rather simple, doesn't it? I am playing with VibrantCMS, another W...
    • Tom:Good article...I am glad that you mentioned internal linking. I don't think en...
    • Tom:I really like the template...it is very functional yet clean...
    • Mike:Thanks for the tip. I added the links to the blog - easy and works great. ...
    • simon:i feel that to get success with your site or blog, concentration is very import...
Copyright
Links
© 2008 - 2009 ThemeLib. Arthemia Theme by MichaelJubel - Enhanced by ThemeLib
Cheap Web Hosting UK Provider | Best Website Hosting UK | Complaints
Choose the best Hosting for your website | Web Hosting UK by pickaweb.co.uk