Are you looking for ways to quickly and easily display today’s date in WordPress? If so, you’re in the right place! In this blog post, I’ll provide you with a step-by-step guide how to display today’s date in WordPress using PHP, JavaScript, short codes, widgets, and plugins.
By the end of this article, you’ll have a better understanding of how to display the date in WordPress and which plugins you should use. So let’s get started!
Introduction to Displaying Date in WordPress
Displaying the date in WordPress is an important part of any website or blog. It allows your readers to know when a post or page was last updated, when a comment was posted, or even when a giveaway or special offer is expiring. You probably noticed that many news websites display the current date in the header section of their websites like in our example the New York Times. Similarly, blogs and online journals have adopted this format as well, displaying the current day in their headers. As a result, visitors to the blog could rest comfortably that they were seeing the most recent entries.

Displaying today’s date is also significant for SEO purposes. Search engines use the date to figure out how relevant content is, so putting the date in a prominent place can help your posts and pages rank higher in search results.
WordPress does not come with a default widget or block to display current date or time. Many of the WordPress themes available offer the ability to display today’s date without the need for any coding. However, using some very simple code you can add today’s date and/or only display current date or time on your WordPress site.
As said above, there are several ways to display the date. In the next sections, we’ll look at each method in more detail.
Why should you display today’s date on your WordPress website?
On the headers of some sites, you can see the date – this is especially true for small news sites whose main content is made every day. So customers can be sure they are looking at the most up-to-date online version. These styles are also often used by blogs and magazines on the internet. So that people who went to the site could feel good about the information on their page. The time feature on a WordPress site is a great way to show the current date in a clear way. You can also show the customer how long they have to use live chat.
How to Display Date in WordPress Using PHP
The most basic way to display the WP date is to use PHP Code. In WordPress, all core files are written in PHP, so it’s easy to add a bit of code to any post, page, or template to display the date.
For example, if you wanted to display today’s PHP date, you could use the following code:
?php echo date( 'F j, Y' ); ?>
This code will display the full date (e.g. April 13, 2020). However, if you want to display a different format (e.g. April 13th, 2020), you can use the following code:
?php echo date( 'F jS, Y' ); ?>
The code you use will depend on the time format you want to display. You can find a list of available formats here.
How to Display Date in WordPress Using JavaScript
If you’re not comfortable with PHP, you can also display the WP date using JavaScript. The code is very similar to PHP, but with a few minor differences.
For example, if you want to know how to display today s date in WordPress via PHP to display today’s date, you could use the following code:
script> document.write( new Date().toLocaleDateString() ); /script>
This code will display the full date (e.g. April 13, 2020). However, if you want to display a different format (e.g. April 13th, 2020), you can use the following code:
script> document.write( new Date().toLocaleDateString('en-US', {day: 'numeric', month: 'long', year: 'numeric'}) ); /script>
The code you use will depend on the format you want to display. You can find a list of available formats here.
How to Display the Date Using Shortcodes
Shortcodes are a great way to display the date without having to write any code. All you need to do is add a shortcode to your post or page, and the date will be displayed automatically.
For example, if you wanted to display today’s date, you could use the following shortcode:
[date]
This shortcode will display the full date including the current month (e.g. April 13, 2020). However, if you want to display a different format (e.g. April 13th, 2020), you can use the following shortcode:
[date format="F jS, Y"]
The code you use will depend on the format you want to display. You can find a list of available formats here.
How to create a shortcode to display today’s date in WordPress?
It can be done manually a little by simply generating shortcodes using just one line of code. Personally, I prefer that method because the time can be inserted anywhere you want. This method also provides flexibility for widgetized pages and widgetized areas as well. You can either use function.php to write the HTML code or use the function.php code to change a theme. Then add it to your functions.php file. Function displayTodaysDate( $atts ) returns date.get-option (date_format));
function b_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;
}
add_shortcode('date-today','b_date_today');
This code simply creates a shortcode that displays the current date. You can use it by adding this shortcode anywhere on your site:
[date-today]
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’]
How to Display Date in WordPress Using Widgets
Displaying the date in WordPress can be useful for a variety of purposes, such as letting your visitors know when a post or page was last updated, or simply providing a sense of context for your content. You can use widgets if you don’t know how to use code or shortcodes or if you just want a quick and easy way to show the date.
Widgets are a powerful and flexible part of WordPress that make it easy to add different kinds of content to the sidebar or footer of your website. You can use the built-in WordPress Date widget to show the date on a WordPress site. You can put the widget in the sidebar or footer of your website by dragging and dropping it there. The current date will show up automatically.
You can also change the way the date is shown with the WordPress Date widget. You can choose from several predefined formats, such as full date (e.g. April 13, 2020) or short date (e.g. Apr 13, 2020), or you can make your own format (e.g. April 13th, 2020). This can be helpful if you want the date to be shown in a certain way or if you want it to match the style and tone of your site.
Using widgets to display the date in WordPress is a simple and effective way to add this type of content to your website. You can quickly add a date widget to your sidebar or footer and start showing the current date on your website with just a few clicks.
How to Display Date Using Plugins
Finally, if you would rather not mess with code, shortcodes, or widgets, you can also display the date in WordPress using plugins. Plugins are easy to install and require very little setup.
For example, if you wanted to display today’s date, you could use the WordPress Date plugin. From the WordPress Dashboard navigate to Plugins -> Add New and simply install the plugin, and the date will be displayed automatically.
The plugin also allows you to customize the format of the date. You can choose from several different formats, including full date (e.g. April 13, 2020), short date (e.g. Apr 13, 2020), and even custom formats (e.g. April 13th, 2020).
Best Plugins for Displaying the Date in WordPress
Now that you know how to display the date in WordPress using PHP, JavaScript, shortcodes, widgets, and plugins, let’s take a look at some of the best plugins for displaying the date.
- WP Date – This plugin is the most popular and feature-rich plugin for displaying the date in WordPress.
It allows you to easily customize the format of the date, select from several different languages, and even add a custom date range.
- Display Date and Time – This plugin is a great choice if you want to display the date and time in different formats. It allows you to choose from several formats, including full date, short date, and custom formats.
- Date and Time Widget – Somewhat older but still works fine. It is a great choice if you want to display the date and time in different languages. It allows you to pick from various languages, including English, French, Spanish, and German.
- Custom Date and Time – This plugin is the most flexible plugin for displaying the date and time in WordPress. It allows you to customize the format of the date and time, pick from several different languages, and even add custom CSS.
Troubleshooting Date Display in WordPress
If you’re having trouble displaying the date, there are a few things you can do to troubleshoot the issue.
- First, make sure you’re using the correct code or shortcode for your version of WordPress. Different versions of WordPress use different code and shortcodes, so make sure you’re using the correct ones.
- Second, make sure you’re using the correct format for the date. Different formats will be displayed differently, so make sure you’re using the correct format for your needs.
Conclusion
Displaying the date in WordPress is an important feature of any website or blog. Your readers will appreciate being reminded to the time of the most recent post or page change, the time a remark was made, or the time an offer expires.
There are numerous methods to show the date. You may modify the site with the use of several programming languages and tools, such as PHP, JavaScript, shortcodes, widgets, and plugins.
Feel free to use the comments section to ask for clarification or to express any concerns you may have. I’m eager to hear from you.
Frequently Asked Questions
There are a few ways to insert the current date in WordPress:
Use the WordPress date shortcode: [date]
Use the PHP date function: <?php echo date(‘F j, Y’); ?>
Use a WordPress plugin: There are many plugins available that allow you to insert the current date and time in various formats.
To insert the date using the shortcode or the PHP function, you will need to edit your theme files. You can do this by going to Appearance > Editor in the WordPress admin dashboard. Once you have located the appropriate template file, you can insert the shortcode or PHP function wherever you want the date to appear.
If you prefer to use a plugin, you can search for “date” in the Plugin Directory and choose a plugin that meets your needs. After installing and activating the plugin, you can use its shortcode or function to insert the date wherever you want on your site.
To insert the current date in HTML, you can use the JavaScript Date object. Here is an example of how to do this:
<script>
var currentDate = new Date();
document.write(currentDate);
</script>
This will insert the current date and time in the format “Wed Jan 05 2022 12:00:00 GMT-0800 (Pacific Standard Time)”.
To get the current date and time in WordPress, you can use the current_time() function. This function retrieves the current date and time in the WordPress timezone.
Here is an example of how to use this function:
$current_time = current_time( 'mysql' );
This will return the current date and time in the MySQL format, which is YYYY-MM-DD HH:MM:SS.
Our other Blog posts

How to Fix the WordPress White Screen of Death
The WordPress white screen of death is among the most frequent WordPress issues. Because there is no error notice and

What is a WordCamp?
WordCamp is a conference about everything WordPress-related. WordPress is a popular content management system (CMS) that runs millions of websites

How to Edit wp-config.php in WordPress
Have you seen a tutorial that instructs you to update the wp-config file on your website, but you have no