Show the current date in WordPress without a plugin

You are currently viewing Show the current date in WordPress without a plugin

I wanted a way of displaying the current date in WordPress. Ideally, I wanted to use a shortcode that would display it.

After I checked out the built-in shortcodes native to WordPress, and verified there was not a shortcode for displaying the current date, I looked for a plugin that did it. I found quite a few plugins that generated a shortcode to display the current date. I then thought about adding yet another plugin to my website just to display the date.

I decided to create it myself without a plugin.

This is what I came up with:

I copied the above code and pasted at the end of the function.php file in my website’s theme folder. I then placed the following shortcode where I wanted the current date to be displayed:

[[display_current_date]]

The result was the following:

[display_current_date]

I formatted the PHP date() function with the following format parameters:

l” – A full textual representation of the day of the week.
j” – The day of the month without leading zeros.
F” – A full textual representation of a month, such as January or March.
Y” – A full numeric representation of a year with four digits.

If you would like to use this code, but want to change the way the current date gets displayed, you can see a full list of the format parameters by going here.

Rick Rottman

My name is Rick Rottman, and this is my personal website. I was born and raised in Southern California, but I've lived most of my adult life in Maryland. I'm an U.S. Air Force veteran. I collect a plethora of frivolous things. I'm a WordPress enthusiast.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.