display today's date in WordPress

Want to know how to display today’s date in WordPress?

Of course you do. That’s why you’re here and that’s exactly what we’re going to show you how to do.

We know that there are several reasons why you might want to display today’s date on your WordPress site. 📟 For example, many blogs, online journals, and news websites display the date to assure visitors the articles they are seeing are recent. Another reason would be to show the current day and time on live chat features and countdown timers.

Whatever your specific reason is for wanting to display today’s date in WordPress, we will show you ⏩ three easy ways how you can do it: using a plugin, writing your own code, or opting for a shortcode.

Let’s dive right into it, shall we? 🤿

Why show today’s date in WordPress

You’ve probably noticed many news journals and other online sources add dates to their blog posts. That’s because displaying the date in WordPress has multiple advantages. Let’s take a look at some of them:

  • 🌱 Freshness: Showing the current date on your website can make it look more up-to-date and relevant to your visitors. It can help build trust with your audience and keep them coming back for new content. However, you have to be consistent with your uploads if you want this to work, as there’s no point in adding dates if you don’t plan on posting regularly.
  • ⏱️ Time-sensitive content: If you publish time-sensitive content, such as news articles or event listings, displaying the current date can help visitors determine the relevance of the content. Your readers will see you’re covering the latest news, making your source more reliable.

Now that we’ve covered why it can be beneficial, let’s go over all the steps you need to take to display today’s date in WordPress.

Easy ways to display today’s date in WordPress

The first thing we should mention is that WordPress itself does not come with a widget or block that would allow you to add the current date to your posts or pages automatically. This is why many people have turned to writing their own simple code or using specific tools to do this. You don’t need much knowledge to do it yourself, either.

Although there are more complicated ways to display today’s date in WordPress, we’ll show the three most common and popular ones below. Let’s start with the easiest one: using a plugin made explicitly for this purpose. If you prefer to avoid plugins (many people do), then keep reading to see how you can write your own custom code and shortcode to make displaying today’s date possible.

Method 1: Insert today’s date anywhere using a WordPress plugin

A straightforward way to show today’s date on your WordPress website is to use the plugin method. By this, we mean installing a plugin that creates a widget or component you can use on different pages or templates.

There are a few different options out there, but for this article, we’ll focus on how to show a date using the free plugin WP Date and Time Shortcode.

👉 To use this plugin:

  1. Install WP Date and Time Shortcode by navigating to PluginsAdd New from your dashboard, searching for its name, and clicking on Install.
  2. Activate the plugin from the Plugins menu.
  3. Just paste any of the included shortcodes anywhere on your posts, pages, or templates, and they will work right out of the box.

Here are some examples of usage for this plugin:

  • [wpdts-date-time] – This shortcode will show the default date and time format as seen on your WordPress general settings.
  • [wpdts-date] – The default date format.
  • [wpdts-time] – The default time format.

You can also customize the appearance of the date using the shortcode parameters available. More in the plugin’s docs.

Method 2: Insert today’s date using custom code

You don’t need to be a programmer to use simple PHP code. In fact, there is a surprisingly simple line of code that can display today’s date using the date format you have in your WordPress settings. Here it is:

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

So, where do you need to add this bit of code? Unlike a shortcode, which can be pasted on any WordPress post or page, this piece of PHP code can only be used in your theme files. You can see these files by going to Appearance Theme File Editor from your dashboard.

You can add your current date function on any of your theme files to display today's date in WordPress

If you want to change the way the date is displayed (for example, the order of the day and month), you can do this by visiting your Settings page (Settings General).

Method 3: Insert today’s date using a custom shortcode

The method we just covered, writing your own code, limits where you can display the date as it can only be pasted in theme files. If you want to add your date widget or block on any post or page, you can instead write your own shortcode.

To do this, the first step is to create the shortcode code itself. Then, you can place that code either in your functions.php file or set it up via a custom code snippet using the Code Snippets plugin (recommended).

The shortcode code itself is this:

add_shortcode( 'date-today', function ($atts) {
	return date(get_option('date_format'));
} );

Once you have added this shortcode definition to either the Code Snippets plugin or to your functions.php file, you can use the following shortcode to display today’s date anywhere on your site:

[date-today]
Adding the shortcode to a WordPress post to display the current date

If you change the formatting of the shortcode within your post (for example, you make the text bold), this will also be applied in the front end.

Final thoughts 🧐

Learning how to display today’s date in WordPress is a useful thing you can learn quickly and easily. There’s no singular way of doing that, so you can choose between several equally effective methods.

Whether you decide to use the WP Date and Time plugin, create a custom shortcode, or come up with a manual code, we hope this guide will help you achieve your desired results.

Once you implement the necessary steps, you’ll be able to enjoy all the benefits of showing the date and time on your WordPress posts. Not only will the content look fresher, but it will also be more organized.

Do you have any questions about how to display today’s date in WordPress? Let us know in the comments below!

Free guide

4 Essential Steps to Speed Up
Your WordPress Website

Follow the simple steps in our 4-part mini series
and reduce your loading times by 50-80%. 🚀

Free Access

0 Comments
Inline Feedbacks
View all comments

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!