How to Manually Display Todays Date in WordPress

todays date
http://lpweb.co/1QY2SEU

Have you seen one of those sites which display todays date at the top of their website. It looks pro, doesn’t it? As more and more WordPress powered sites are using newspaper layout themes, displaying todays date is a nice little feature to have. WordPress is powered by PHP and displaying todays date is very simple. All you need to display todays date is the following code snippet

echo date( 'l jS F Y' );

Most commonly, you would be placing the code snippet in header.php file of your theme but you can place it anywhere you want. The above snippet of code will display date in the following format

Thursday 4th February 2016

As you can see, all we are doing is calling the PHP date function. If you want to change how the date gets displayed, then check the official PHP date documentation.

Displaying todays date in WordPress settings format

WordPress allows Admin users to set a date format for their blog (configured in Dashboard > Settings > Date Format). If you want to display today’s date in the date format set in the settings panel, then you will have to make a small change to your code. Instead of specifying a date format, we will have to grab the one in the settings. Use the following code snippet

echo date( get_option( 'date_format' ) );

 

Error Establishing a Database Connection

Next Article

How to Fix the Error Establishing a Database Connection in WordPress

Tapas Pal

Tapas pal is the founder of layerpoint.com and he is an avid Internet geek enthusiast and writer has deep interest in technology, Digital Marketing and love tools that increase human productivity.