How to Display Today’s Date in WordPress (2 Easy Methods)
-
by cobra_admin
- 53
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.

Why Display Today’s Date in WordPress?
Many news websites display the current date in the header section of their sites, particularly smaller news sites that publish their main stories on a daily basis.

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 adopted this style. This assures users that they are viewing the latest entries on a blog.
There are other usage scenarios where you may just want to show the current date and time.
For instance, if your live chat works at specific hours and you want to show customers what time it is in your geographic location. Or, you are running a countdown timer campaign and want to show the 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 WordPress website. We will cover two methods:
- Displaying Today’s Date by Adding Code to a Template File
- Displaying Today’s Date Anywhere Using Shortcode
Method 1: Displaying Today’s Date by Adding Code to a Template File
WordPress doesn’t come with a default widget or block to display the current date or time.
However, you can still display the current date or time using some very simple code.
You can add this simple code to your WordPress theme’s template files where you want to display the time:
1 | <?php echo date (get_option( 'date_format' )); ?> |
Hosted with ❤️ by WPCode
1-click Use in WordPress
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.

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.
1 | <?php echo date ( 'F j, Y' ); ?> |
Hosted with ❤️ by WPCode
1-click Use in WordPress

This method allows you to directly add the code to WordPress theme files, but it is not very flexible. What if you wanted to display the current date and time inside a WordPress post, page, or sidebar widget?
This next method allows you to add the date and time anywhere on your site.
Method 2: Displaying Today’s Date Anywhere Using Shortcode (Recommended)
For this method, we will create a shortcode and then use it to display the date and time anywhere on our WordPress website.
You can add the following code to your theme’s functions.php file or by using a custom code snippets plugin such as WPCode (recommended):
12345678910111213 | 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 ; } add_shortcode( 'date-today' , 'wpb_date_today' ); |
Hosted with ❤️ by WPCode
1-click Use in WordPress

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']

We hope this article helped you learn how to easily display today’s date in WordPress. You may also want to see our guide on how to add a weather forecast in WordPress or our expert picks for the best quiz plugins for WordPress.
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…
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…