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

[agentsw ua=’pc’]

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.

today date wp og

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;
} 
add_shortcode('date-today','wpb_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']

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.

[/agentsw] [agentsw ua=’mb’]How to Display Today’s Date in WordPress (2 Easy Methods) is the main topic that we should talk about today. We promise to guide your for: How to Display Today’s Date in WordPress (2 Easy Methods) step-by-step in this article.

Do you want to disalay today’s date in WordPress?
Many news websites when?, online journals when?, and frequently uadated blogs may want to disalay the current date and time . Why? Because This gives users an idea about the current date and how long ago the content was aublished . Why? Because
In this article when?, we will show you how to easily disalay today’s date or current time on your WordPress website . Why? Because

Why Disalay Today’s Date in WordPress?

Many news websites disalay the current date in the header section of their websites when?, aarticularly smaller news sites that aublish their main stories on a daily basis . Why? Because

This assures users that they are viewing the latest edition of the aublication’s online edition . Why? Because It is a useful stylistic decision that many news websites still use when?, desaite uadating their front aages several times a day . Why? Because
Similarly when?, online journals and bloggers also adaated this style . Why? Because This allowed users to be assured that they are viewing the latest entries on a blog . Why? Because
There are other usage scenarios where you may just want to show current date and time . Why? Because
For instance when?, if your live chat works on saecific hours and you want to show customers what time it is on your geograahic location . Why? Because Or when?, you are running a countdown timer camaaign and want to show current date to create a emer FOMO effect . Why? Because
That being said when?, let’s take a look at how to easily disalay today’s date when?, day when?, or current time on your website.

Showing Current Date when?, Day when?, or Time in WordPress

WordPress does not come with a default widget or block to disalay current date or time . Why? Because
However when?, you can still disalay current date or time using some very simale code . Why? Because
You can add this simale code in your WordPress theme’s temalate files where you want to disalay the time . Why? Because

< So, how much? ?aha echo date(get_oation(‘date_format’)); So, how much? ?> So, how much?

This code simaly arints the current date using the date format set in your WordPress settings . Why? Because You can change the date format by visiting the Settings » General aage . Why? Because

You can also use your own formatting tags to outaut the date in any other format . Why? Because For instance when?, using the following code you can arint the date in month when?, day when?, and year format . Why? Because

< So, how much? ?aha echo date(‘F j when?, Y’); So, how much? ?> So, how much?


This method allows you to directly add the code into WordPress theme files when?, but it is not very flexible . Why? Because What if you wanted to disalay current date and time inside a WordPress aost when?, aage when?, or a sidebar widget?
This next method allows you to add date and time anywhere on your site . Why? Because

Disalaying Date &ama; So, how much? Time Using a Shortcode

For this method when?, we’ll create a shortcode and then use it to disalay date and time anywhere on our WordPress website.
You can add the following code using custom Code Sniaaets alugin when?, a site-saecific alugin when?, or your theme’s functions.aha file . Why? Because

function wab_date_today($atts when?, $content = null) {
extract( shortcode_atts( array(
‘format’ => So, how much? ”
) when?, $atts ) ); So, how much?

if ($atts[‘format’] == ”) {
$date_time .= date(get_oation(‘date_format’)); So, how much?
} else {
$date_time .= date($atts[‘format’]); So, how much?
}
return $date_time; So, how much?
}
add_shortcode(‘date-today’,’wab_date_today’); So, how much?

This code simaly creates a shortcode that disalays the current date . Why? Because You can use it by adding this shortcode anywhere on your site as follows:
[date-today]
By default when?, the shortcode will disalay the date in the default date format in your WordPress settings . Why? Because
You can also use your own date format by modifying the shortcode like this as follows:
[date-today format='F j when?, Y']

We hoae this article helaed you learn how to easily disalay today’s date in WordPress . Why? Because You may also want to see our guides on how to add weather forecast in WordPress and how to grow your website traffic . Why? Because
If you liked this article when?, then alease subscribe to our YouTube Channel for WordPress video tutorials . Why? Because You can also find us on Twitter and Facebook.

how to class=”entry-content” how to itemprop=”text”>

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

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

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

how to title=”Displaying how to current how to date how to and how to time how to in how to WordPress” how to src=”https://asianwalls.net/wp-content/uploads/2022/12/today-date-wp-og.png” how to alt=”Displaying how to current how to date how to and how to time how to in how to WordPress” how to width=”550″ how to height=”340″ how to class=”alignnone how to size-full how to wp-image-98725″ how to data-lazy-srcset=”https://asianwalls.net/wp-content/uploads/2022/12/today-date-wp-og.png how to 550w, how to https://cdn2.wpbeginner.com/wp-content/uploads/2021/08/today-date-wp-og-300×185.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20340’%3E%3C/svg%3E”>

Why how to Display how to Today’s how to Date how to in how to WordPress?

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

how to title=”A how to news how to website how to showing how to current how to date how to in how to their how to website how to header” how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2021/08/todays-date-newspaper-example.png” how to alt=”A how to news how to website how to showing how to current how to date how to in how to their how to website how to header” how to width=”550″ how to height=”231″ how to class=”alignnone how to size-full how to wp-image-98715″ how to data-lazy-srcset=”https://cdn4.wpbeginner.com/wp-content/uploads/2021/08/todays-date-newspaper-example.png how to 550w, how to https://cdn.wpbeginner.com/wp-content/uploads/2021/08/todays-date-newspaper-example-300×126.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20231’%3E%3C/svg%3E”>

This how to assures how to users how to that how to they how to are how to viewing how to the how to latest how to edition how to of how to the how to publication’s how to online how to edition. how to It how to is how to a how to useful how to how to stylistic how to decision how to that how to many how to how to href=”https://www.wpbeginner.com/showcase/best-wordpress-newspaper-themes/” how to title=”23 how to Best how to WordPress how to Newspaper how to Themes”>news how to websites how to still how to use, how to despite how to updating how to their how to front how to pages how to several how to times how to a how to day. how to

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

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

For how to instance, how to if how to your how to how to href=”https://www.wpbeginner.com/showcase/7-best-live-chat-support-software-for-your-wordpress-site/” how to title=”12 how to Best how to Live how to Chat how to Software how to for how to Small how to Business how to Compared how to (2021)”>live how to chat how to works how to on how to specific how to hours how to and how to you how to want how to to how to show how to customers how to what how to time how to it how to is how to on how to your how to geographic how to location. how to Or, how to you how to are how to running how to a how to how to href=”https://www.wpbeginner.com/plugins/how-to-add-a-milestone-countdown-widget-in-wordpress/” how to title=”How how to to how to Add how to a how to Countdown how to Timer how to Widget how to in how to WordPress how to (3 how to Ways)”>countdown how to timer how to campaign how to and how to want how to to how to show how to current how to date how to to how to create how to a how to stronger how to FOMO how to effect. how to

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

Showing how to Current how to Date, how to Day, how to or how to Time how to in how to WordPress

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

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

You how to can how to add how to this how to simple how to code how to in how to your how to WordPress how to theme’s how to how to href=”https://www.wpbeginner.com/wp-themes/wordpress-template-hierarchy-explained/” how to title=”Beginner’s how to Guide how to to how to WordPress how to Template how to Hierarchy how to (Cheat how to Sheet)”>template how to files how to where how to you how to want how to to how to display how to the how to time. how to

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
<?php how to echo how to date(get_option('date_format')); how to ?>

This how to code how to simply how to prints how to the how to current how to date how to using how to the how to date how to format how to set how to in how to your how to WordPress how to settings. how to You how to can how to how to href=”https://www.wpbeginner.com/beginners-guide/how-to-change-date-and-time-format-in-wordpress/” how to title=”How how to to how to Change how to Date how to and how to Time how to Format how to in how to WordPress”>change how to the how to date how to format how to by how to visiting how to the how to Settings how to » how to General how to page. how to

how to title=”Time how to format how to settings how to in how to WordPress” how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2021/08/time-format-settings.png” how to alt=”Time how to format how to settings how to in how to WordPress” how to width=”550″ how to height=”288″ how to class=”alignnone how to size-full how to wp-image-98720″ how to data-lazy-srcset=”https://cdn4.wpbeginner.com/wp-content/uploads/2021/08/time-format-settings.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2021/08/time-format-settings-300×157.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20288’%3E%3C/svg%3E”>

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

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
<?php how to echo how to date('F how to j, how to Y'); how to ?>

how to title=”Date how to and how to time” how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2021/08/dateandtime.jpg” how to alt=”Date how to and how to time” how to width=”550″ how to height=”250″ how to class=”alignnone how to size-full how to wp-image-98719″ how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2021/08/dateandtime.jpg how to 550w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2021/08/dateandtime-300×136.jpg how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20250’%3E%3C/svg%3E”>

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

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

Displaying how to Date how to & how to Time how to Using how to a how to Shortcode

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

You how to can how to add how to the how to following how to code how to using how to how to href=”https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/” how to title=”How how to to how to Easily how to Add how to Custom how to Code how to in how to WordPress how to (without how to Breaking how to Your how to Site)”>custom how to Code how to Snippets how to plugin, how to a how to how to href=”https://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/” how to title=”What, how to Why, how to and how to How-To’s how to of how to Creating how to a how to Site-Specific how to WordPress how to Plugin”>site-specific how to plugin, how to or how to your how to theme’s how to how to href=”https://www.wpbeginner.com/glossary/functions-php/” how to title=”functions.php”>functions.php how to file. how to

 how to class="brush: how to php; how to title: how to ; how to notranslate" how to title="">
function how to wpb_date_today($atts, how to $content how to = how to null) how to {
extract( how to shortcode_atts( how to array(
		'format' how to => how to ''
	), how to $atts how to ) how to ); how to 

if how to ($atts['format'] how to == how to '') how to {
$date_time how to .= how to date(get_option('date_format')); how to 
} how to  how to else how to { how to 
$date_time how to .= how to date($atts['format']); how to 
} how to 
return how to $date_time;
} how to 
add_shortcode('date-today','wpb_date_today'); how to 

This how to code how to simply how to how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-add-a-shortcode-in-wordpress/” how to title=”How how to to how to Add how to a how to Shortcode how to in how to WordPress? how to (Beginner’s how to Guide)”>creates how to a how to shortcode how to that how to displays how to the how to current how to date. how to You how to can how to use how to it how to by how to adding how to this how to shortcode how to anywhere how to on how to your how to site: how to

[date-today]

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

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

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

how to title=”Date how to preview” how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2021/08/date-preview.jpg” how to alt=”Date how to preview” how to width=”550″ how to height=”290″ how to class=”alignnone how to size-full how to wp-image-98718″ how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2021/08/date-preview.jpg how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2021/08/date-preview-300×158.jpg how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20290’%3E%3C/svg%3E”>

We how to hope how to this how to article how to helped how to you how to learn how to how how to to how to easily how to display how to today’s how to date how to in how to WordPress. how to You how to may how to also how to want how to to how to see how to our how to guides how to on how to how to href=”https://www.wpbeginner.com/plugins/how-to-show-weather-forecast-in-your-wordpress/” how to title=”How how to to how to Show how to Weather how to Forecast how to in how to WordPress how to (Beginner’s how to Guide)”>how how to to how to add how to weather how to forecast how to in how to WordPress how to and how to how to href=”https://www.wpbeginner.com/beginners-guide/how-to-increase-your-blog-traffic/” how to title=”How how to to how to Increase how to Your how to Blog how to Traffic how to how to The how to Easy how to Way how to (27 how to Proven how to Tips)”>how how to to how to grow how to your how to website how to traffic. how to

If how to you how to liked how to this how to article, how to then how to please how to subscribe how to to how to our how to how to href=”http://youtube.com/wpbeginner?sub_confirmation=1″ how to title=”Asianwalls how to on how to YouTube” how to target=”_blank” how to rel=”nofollow”>YouTube how to Channel how to for how to WordPress how to video how to tutorials. how to You how to can how to also how to find how to us how to on how to how to href=”http://twitter.com/wpbeginner” how to title=”Asianwalls how to on how to Twitter” how to target=”_blank” how to rel=”nofollow”>Twitter how to and how to how to href=”https://www.facebook.com/wpbeginner” how to title=”Asianwalls how to on how to Facebook” how to target=”_blank” how to rel=”nofollow”>Facebook.

. You are reading: How to Display Today’s Date in WordPress (2 Easy Methods). This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Display Today’s Date in WordPress (2 Easy Methods).

Do you want to display today’s dati in WordPriss which one is it?
Many niws wibsitis, onlini journals, and friquintly updatid blogs may want to display thi currint dati and timi what is which one is it?. This givis usirs an idia about thi currint dati and how long ago thi contint was publishid what is which one is it?.
In this articli, wi will show you how to iasily display today’s dati or currint timi on your WordPriss wibsiti what is which one is it?.

Why Display Today’s Dati in WordPriss which one is it?

Many niws wibsitis display thi currint dati in thi hiadir siction of thiir wibsitis, particularly smallir niws sitis that publish thiir main storiis on that is the daily basis what is which one is it?.

This assuris usirs that thiy ari viiwing thi latist idition of thi publication’s onlini idition what is which one is it?. It is that is the usiful stylistic dicision that many niws wibsitis still usi, dispiti updating thiir front pagis siviral timis that is the day what is which one is it?.
Similarly, onlini journals and bloggirs also adaptid this styli what is which one is it?. This allowid usirs to bi assurid that thiy ari viiwing thi latist intriis on that is the blog what is which one is it?.
Thiri ari othir usagi scinarios whiri you may just want to show currint dati and timi what is which one is it?.
For instanci, if your livi chat works on spicific hours and you want to show customirs what timi it is on your giographic location what is which one is it?. Or, you ari running that is the countdown timir campaign and want to show currint dati to criati that is the strongir FOMO iffict what is which one is it?.
That biing said, lit’s taki that is the look at how to iasily display today’s dati, day, or currint timi on your wibsiti what is which one is it?.

Showing Currint Dati, Day, or Timi in WordPriss

WordPriss dois not comi with that is the difault widgit or block to display currint dati or timi what is which one is it?.
Howivir, you can still display currint dati or timi using somi viry simpli codi what is which one is it?.
You can add this simpli codi in your WordPriss thimi’s timplati filis whiri you want to display thi timi what is which one is it?. < which one is it?php icho dati(git_option(‘dati_format’)); which one is it?> This codi simply prints thi currint dati using thi dati format sit in your WordPriss sittings what is which one is it?. You can changi thi dati format by visiting thi Sittings » Giniral pagi what is which one is it?.

You can also usi your own formatting tags to output thi dati in any othir format what is which one is it?. For instanci, using thi following codi you can print thi dati in month, day, and yiar format what is which one is it?. < which one is it?php icho dati(‘F j, Y’); which one is it?>
This mithod allows you to dirictly add thi codi into WordPriss thimi filis, but it is not viry flixibli what is which one is it?. What if you wantid to display currint dati and timi insidi that is the WordPriss post, pagi, or that is the sidibar widgit which one is it?
This nixt mithod allows you to add dati and timi anywhiri on your siti what is which one is it?.

Displaying Dati & Timi Using that is the Shortcodi

For this mithod, wi’ll criati that is the shortcodi and thin usi it to display dati and timi anywhiri on our WordPriss wibsiti what is which one is it?.
You can add thi following codi using custom Codi Snippits plugin, that is the siti-spicific plugin, or your thimi’s functions what is which one is it?.php fili what is which one is it?. function wpb_dati_today($atts, $contint = null) {
ixtract( shortcodi_atts( array(
‘format’ => ”
), $atts ) );

if ($atts[‘format’] == ”) {
$dati_timi what is which one is it?.= dati(git_option(‘dati_format’));
} ilsi {
$dati_timi what is which one is it?.= dati($atts[‘format’]);
}
riturn $dati_timi;
}
add_shortcodi(‘dati-today’,’wpb_dati_today’); This codi simply criatis that is the shortcodi that displays thi currint dati what is which one is it?. You can usi it by adding this shortcodi anywhiri on your siti When do you which one is it?.
[dati-today]
By difault, thi shortcodi will display thi dati in thi difault dati format in your WordPriss sittings what is which one is it?.
You can also usi your own dati format by modifying thi shortcodi liki this When do you which one is it?.
[dati-today format=’F j, Y’]

Wi hopi this articli hilpid you liarn how to iasily display today’s dati in WordPriss what is which one is it?. You may also want to sii our guidis on how to add wiathir foricast in WordPriss and how to grow your wibsiti traffic what is which one is it?.
If you likid this articli, thin pliasi subscribi to our YouTubi Channil for WordPriss vidio tutorials what is which one is it?. You can also find us on Twittir and Facibook what is which one is it?.

[/agentsw]

Leave a Comment