• How To Display Current Date and Time On WordPress Theme Header

    If you have a magazine blog or just like newspapers want to display current date and time on your blog then this post is for you. Now people are moving from a simple blog to professional magazine style theme blog to add both features and looks.

    If your blog posts displaying the date of publishing then it is a great idea to display the current date that makes your blog a little bit more professional. It gives a complete idea at a glance that how frequently the blog posts update and builds a trust relationship with your audience.

    You might think to add this functionality require so many steps then you need to think again because it is simple and uses only single line code.

    1# Coding Method To Setup Current Date and Time

    Step 1: Go to your admin dashboard of WordPress and click on the editor and select the theme where you want to enable this features.

    WordPress current date and time

    Edit theme wordpress to add current date and time

    Step 2: Now from the right side column select the header.php theme file. Now from the editing area search for  </head> or </header> and paste the below given code before it

    1
    <?php echo date(get_option('date_format')); ?>

    Example screenshot:

    How to display the current date and time on the wordpress header

    This code will pull the date format you have set in under Settings > General -> date format.

    If you want to give your own style or date format then you can use this command instead of above.

    1
    <?php echo date('l jS F Y'); ?>

    The code given above will show the date format as Thursday, 12th September 2017.

    You can also try other date formats if you don’t the above one just visit the PHP Date Manual for other parameters.

    2# Second Method is using the plugin

    The second method is using the plugin which easy and safe.  There are not so many plugins those offers this type of functionality but thanks, Date and Time Widget is there. The plugin is not updated frequently but we test it with WordPress 4.8.1 and it works without any issues.

    How To set up current Date and Time Widget plugin for WordPress:

    Step 1: Go to WordPress dashboard and click Plugins-> Add new and search for Date and Time Widget.

    Step 2: The search result will show the plugin and now click on the Install and then Activate.

    Date and time widget wordpress

    Step 3: After installing the plugin go to Appereance-> Widget and look for Widget called Date and Time.

     

    Step 4: Select the Widget and save it under the Header Widget area as shown in the screenshot.

    How to Display Todays curent Date in WordPress

    Step 5: After selecting the Widget to go to Header Widget area and configure the color, date and time format, Date font family and size.

    header widger area in wordpress to set current date and time

    Step 6: Save the Widget and now go to your website and see the magic!!

    Plugin shortcode to setup display current date and time on wordpress header

     

    Leave a Reply

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