Free Wordpress Blog Setup

How to Display Today’s Date in WordPress?

By Editorial Staff in Tutorials
How to Display Today’s Date in WordPress?

A trend of displaying current date which was started with newspapers has been adapted by many blogs. As more and more users are using WordPress to create magazine style theme, this is just one of the features that can be a great addon to your site. Having a current date looks professional, and it is certainly useful if your articles are dated. You might think that adding a date to WordPress is hard and will require multiple steps, but it is a short and simple method. In this article, we will share a snippet that will allow you to display today’s date in WordPress or any other PHP based website.

All you need to do is place the following code in a theme file of your choice, most commonly in header.php:

<?php echo date('l jS F Y'); ?>

The above code will display the date in the following format:

Thursday, 17th September 2009

If you do not like the formatting above, you can look at the PHP Date Manual for other parameters.

Now another way to do this is by just extracting your WordPress admin settings. You can go to Settings > General and select the date format in there and simply add this code instead of the above one:

<?php echo date(get_option('date_format')); ?>

Free Wordpress Blog Setup

Comments

4 Responses to “How to Display Today’s Date in WordPress?”
  1. Chase Adams says:

    I wrote a tutorial that piggy backs on this. I’ve taken the already available features of PHP in Wordpress and used it in conjunction with CSS to make totally replaced (and web-standards compliant) dates.

    http://www.chaseadamsphotography.com/2009/09/07/completely-replace-your-text-dates-in-wordpress-with-images-2/

  2. Cheap Sites says:

    Yeah, that was really simple! Thank you for sharing =D

  3. Chase Adams says:

    Why not just use Isn’t it a lot easier as a built in function where you can change the display type in Settings > General ?

  4. andreeib says:

    I used to make this using a short code function in Wordpress.

Share Your Opinions

Tell us what you're thinking...
and if you want a pic to show with your comment, then get gravatar!

Please make sure that you have read our Comment Policy.

Due to high volume of request from our readers, we are adding this feature that allows you to stay updated with this post's comments without having to participate in the discussion even though we would love your input as always. Don't worry we hate SPAM just as much as you do, so you will never receive any SPAM messages from our site and that's our promise to you.

Subscribe without commenting

Close Bar