Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Display Today’s Date in WordPress (2 Easy Methods)

Do you want to display today’s date in WordPress?

Many news websites, online journals, and frequently updated blogs may want to display the current date and time. This gives users an idea about the current date and how long ago the content was published.

In this article, we will show you how to easily display today’s date or current time on your WordPress website.

Displaying current date and time in WordPress

Why Display Today’s Date in WordPress?

Many news websites display the current date in the header section of their websites, particularly smaller news sites that publish their main stories on a daily basis.

A news website showing current date in their website header

This assures users that they are viewing the latest edition of the publication’s online edition. It is a useful stylistic decision that many news websites still use, despite updating their front pages several times a day.

Similarly, online journals and bloggers also adapted this style. This allowed users to be assured that they are viewing the latest entries on a blog.

There are other usage scenarios where you may just want to show current date and time.

For instance, if your live chat works on specific hours and you want to show customers what time it is on your geographic location. Or, you are running a countdown timer campaign and want to show current date to create a stronger FOMO effect.

That being said, let’s take a look at how to easily display today’s date, day, or current time on your website.

Showing Current Date, Day, or Time in WordPress

WordPress does not come with a default widget or block to display current date or time.

However, you can still display current date or time using some very simple code.

You can add this simple code in your WordPress theme’s template files where you want to display the time.

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

This code simply prints the current date using the date format set in your WordPress settings. You can change the date format by visiting the Settings » General page.

Time format settings in WordPress

You can also use your own formatting tags to output the date in any other format. For instance, using the following code you can print the date in month, day, and year format.

<?php echo date('F j, Y'); ?>

Date and time

This method allows you to directly add the code into WordPress theme files, but it is not very flexible. What if you wanted to display current date and time inside a WordPress post, page, or a sidebar widget?

This next method allows you to add date and time anywhere on your site.

Displaying Date & Time Using a Shortcode

For this method, we’ll create a shortcode and then use it to display date and time anywhere on our WordPress website.

You can add the following code using custom Code Snippets plugin, a site-specific plugin, or your theme’s functions.php file.

function wpb_date_today($atts, $content = null) {
extract( shortcode_atts( array(
		'format' => ''
	), $atts ) ); 

if ($atts['format'] == '') {
$date_time .= date(get_option('date_format')); 
}  else { 
$date_time .= date($atts['format']); 
return $date_time;

This code simply creates a shortcode that displays the current date. You can use it by adding this shortcode anywhere on your site:


By default, the shortcode will display the date in the default date format in your WordPress settings.

You can also use your own date format by modifying the shortcode like this:

[date-today format='F j, Y']

Date preview

We hope this article helped you learn how to easily display today’s date in WordPress. You may also want to see our guides on how to add weather forecast in WordPress and how to grow your website traffic.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

24 CommentsLeave a Reply

  1. I really wanted to use this, however, after adding it to my functions file, I get this:
    Warning: Illegal string offset ‘format’ in /XXXXXXXXXX/functions.php

    It showed the date, however, the warning showed up too.

    • Thank you for letting us know, we will look into this and for the time being the second shortcode with the format specified will avoid that warning.


  2. Hi, thank you for the code.

    It’s possible to show the month in spanish and/or in number?


    • For adding the date as numbers if you are using the echo date method, you would change F j, Y to m/d/Y


  3. Is it possible to display a moving date? For instance, today’s date plus 7 days? I’d like to have something on my site that always displays the date one week from today.

  4. Adding this php code in the header file is OK but how can I control where I want to appear my date on the page?

  5. Or with Javascript:

    var dateToday = new Date(); var yearToday = dateToday.getFullYear(); document.write(yearToday);

    • Using CSS you can change the colors. To use css add the date template tag like this:

      <span class="date"><?php echo date('l jS F Y'); ?></span>

      Now in your theme’s style sheet you can add CSS, like this:

      .date { 
      color: blue;
      border: 1px solid #CCC; 


  6. I’m beginning to discover that you can do anything with WP if you just take the time out to learn how – and most of it is so simple. 2011 is the year to ditch plugins and take the weight off my site!

    • We mentioned two solutions. One where you can use the server’s setting, or two where you can use WordPress setting. If you have a third solution, then please share it with us rather than saying that we are wrong because both solutions above work.


Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.