How to 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:

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.

Current Version: 2.6.4

👉 To use this plugin:

Here are some examples of usage for this plugin:

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:

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.

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).

Current Version: 3.3.0

The shortcode code itself is this:

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:

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.

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!

Was this article helpful?
Thanks for your feedback!

This content was originally published here.