How Can You Show Current Date In WordPress Website?
September 16th, 2016 | by Ravi Chahar || 4 Comments |
Nowadays the bloggers want to show current date in WordPress website. There are many WordPress themes which consist this features. But what would you do to display today’s date on your website?
When you see the date on any other website and thinking about showing it on your website then you can easily show that. Most of the blogger seek for the proper solution so that they can add the code in their current theme.
Though there is nothing much to do. You just have to add one line of the code and the date will be showing on your website.
If you good with PHP then you would be aware of the PHP date showing rules. If not then let me give you an example.
Add One Line of PHP Code To Show Current Date In WordPress Website.
You may have noticed that on many websites the date displays at the upper-left corner or the right corner of the website.
If you too want to show the date in the header area then you have to edit the header.php file. If you want to display the date in the footer area then you have to edit the footer.php.
Choose your location and then edit that file. If you know the WordPress theme file structure then it won’t be a problem to edit the theme files.
Let me show you the code:-
The output would be “day,date month year”. For example “Friday, 16th September 2016“. using the above code the year will be showing with the all four digits.
If you want to show only two digits then replace the uppercase “Y” with lowercase “y”. You can check all the ways to show the date using the PHP at PHP Manual.
If you want to show the “AM/PM” then it is possible with the use of simple “A”. There are many other options to display the date format on your website.
You can choose any of them.
Can You Now Show Current Date In WordPress Website?
Though there was nothing hard to look upon. Just the one line of the code. I hope now you can display today’s date on your website.
Just make sure the location of the date. You can use any HTML element to put the date. It would be easy for you to design it according to the color combination of your website.
If you still face any problem then feel free to ask. I will try to provide the best possible solution.
4 comments
Leave a Reply
Hi Ravi, you have a much greater understanding of WordPress and coding than I have! I love reading these technical tips type blogs because I learnt hings I didn’t know before. Thanks so much for sharing!
Enjoy the journey!
Hey Mandy,
Welcome to my blog.:)
We all know that WordPress is a platform on which we can explore a lot. There are many things to learn about. When it comes to the WordPress functions and codex then I love to play with them.
I hope this information can help you in some way.
Thanks for stopping by.
~Ravi
Thanks Ravi!
But I think when it comes to altering the code
I will gladly defer to the pros such as yourself!LOL!
It makes more sense and will definitely save me a lot
of time and unnecessary stress, to let the experts such as yourself,
handle such matters!LOL!
Hey Mark,
If you know about WordPress coding then it won’t be so hard to edit the code. You can add anything you want in the WordPress theme. But on the other side, it’s better to reach out someone with good skills.
You won’t like to get your site broken.
Glad to have you here.
Enjoy the day.
~Ravi