Close Menu
  • Domain Hosting
  • Elementor
  • WooCommerce
  • Error Fixing
  • Optimization
    • WooCommerce Optimization
    • WordPress Database Optimization
    • WordPress Files Optimization
    • WordPress Speed Optimization
  • Loading Speed
  • Security
  • SEO
  • Pro Services

Subscribe to Updates

Get the latest creative news from FooBar about art, design and business.

What's Hot

How to Design a WordPress Website from Scratch?

June 25, 2025

Responsive Design for WordPress Site | wpcarepoint

June 16, 2025

Responsive Design for WordPress Site | wpcarepoint

June 16, 2025
Load More
Facebook LinkedIn Telegram
WordPress Care PointWordPress Care Point
  • Book an Free Appointment
Facebook LinkedIn Telegram
Contact Hire an Expert
Login
  • Domain Hosting
  • Elementor
  • WooCommerce
  • Error Fixing
  • Optimization
    1. WooCommerce Optimization
    2. WordPress Database Optimization
    3. WordPress Files Optimization
    4. WordPress Speed Optimization
    5. View All

    Best Solution for High-Performance WordPress Website in 2024.

    November 16, 2024

    Best Solution for High-Performance WordPress Website in 2024.

    November 16, 2024

    Best Solution for High-Performance WordPress Website in 2024.

    November 16, 2024

    How to Design a WordPress Website from Scratch?

    June 25, 2025

    Responsive Design for WordPress Site | wpcarepoint

    June 16, 2025

    Responsive Design for WordPress Site | wpcarepoint

    June 16, 2025

    Top Web Design Services for Every Business in 2025| wpcarepoint

    May 30, 2025
  • Loading Speed

    Best Solution for High-Performance WordPress Website in 2024.

    November 16, 2024
  • Security
  • SEO
  • Pro Services
  • Domain Hosting
  • Elementor
  • WooCommerce
  • Error Fixing
  • Optimization
  • Loading Speed
  • Security
  • SEO
  • Pro Services
WordPress Care PointWordPress Care Point
Error Fixing

How to show the present date and time in WordPress Website?

Shannon BrookesBy Shannon BrookesNovember 6, 2024Updated:November 18, 2024No Comments6 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Reddit WhatsApp Email
Present Date and Time
how-to-show-present-date-and-time-in-wordpress
Share
Copy Link Facebook Twitter LinkedIn Telegram Pinterest WhatsApp Email Tumblr Reddit VKontakte

How to show the present date and time in WordPress?

In the current world of web development, keeping updated with the present date and time on your WordPress site can increase user experience and keep your content connected. When you’re handling a blog website, an e-commerce website, or a news website, showing the present date and time can deliver your audiences with precious conditions. In this wide guideline, we’ll analyze many techniques to show the present date and time in the WordPress website. You’ll find everything you need to keep your site relevant and expected from code snippets to plugin solutions.

Why show the Present Date and Time?

Before diving into the technical details, let’s consider why you might want to display the present date and time on your WordPress site:

  1. User Engagement: Knowing the date and time can help users understand how current your content is.
  2. Time-Sensitive Information: If you’re sharing news, event details, or updates, showing the present time can make your content more relevant.
  3. Content Personalization: For sites that offer personalized experiences, showing the date and time can increase user reaction.

Method 1: Using WordPress Shortcodes

Shortcodes are an excellent way to add functionality to your WordPress site without needing to write complex code. To display the present date and time using a shortcode, follow these steps:

1. Add a Custom Shortcode

You have to add a custom shortcode to your WordPress theme’s functions.php file. Below is a simple code excerpt to create a shortcode to display the present date and time:

function show_current_datetime() {
    return date('l, F j, Y g:i A');
}
add_shortcode('current_datetime', 'show_current_datetime');

 

 

 

2. Use the Shortcode in Your Posts or Pages

If you will add the shortcode to your functions.php file, you can use it in your posts or pages. Insert the following shortcode where you want the date and time to show:

[current_datetime]

 

This will output the current date and time in the format “August 4, 2024 at 3:45 pm” (assuming this is the current date and time).

Method 2: Using Widgets to Show Date and Time

If you choose a widget-based solution, WordPress offers some plugins that permit you to display the present date and time in your widget areas. Below is a simple method using a plugin:

1. Install a Date and Time Widget Plugin

  1. Go to your WordPress dashboard.
  2. Navigate to Plugins > Add New.
  3. Explore for “Date and Time Widget.”
  4. Install the plugin of your choice, and activate it.
  1. Configure the Widget
  1. Go to Appearance > Widgets.
  2. Find the “Date and Time Widget” (or similar) in your list of available widgets.
  3. Drag and drop your selected widget into your desired section.
  4. Design the widget settings according to your wishes, such as date format and time zone.

This method permits you to simply add a date and time show to your sidebar, footer, or any other widgetized area of your site.

Method 3: Using PHP Code in Theme Files

For those comfortable with editing theme files, you can add PHP code directly to your WordPress theme to show the present date and time. This method requires editing your theme’s header.php, footer.php, or any other template file where you want the date and time to appear.

1. Edit Your Theme File

Navigate to Appearance > Theme Editor and select the template file you want to edit. Add the following PHP code where you want the date and time to be shown:

<?php echo date('l, F j, Y g:i A'); ?>

 

2. Save Your Changes

After adding the code, save the changes. The present date and time will now be shown in the location you identified within the theme file.

Method 4: Using JavaScript for Dynamic Updates

If you choose an effective solution where the date and time automatically update without page refreshes, you can use JavaScript. This method involves adding a bit of JavaScript to your site that updates the date and time in real time.

1. Add JavaScript Code

To include JavaScript, you can either add it bluntly to your theme’s footer or use a custom plugin. There’s a basic example:

 

<span id="current-time"></span>
<script>
function updateDateTime() {
    var now = new Date();
    var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: true };
    document.getElementById('current-time').innerHTML = now.toLocaleString('en-US', options);
}
setInterval(updateDateTime, 1000); // Update every second
</script>

 

 

 

2. Add an HTML Element for Display

In the WordPress theme file where you want to display the present date and time, add the following HTML element:

html shortcode

<div id="present_datetime"></div>

 

This JavaScript code continuously updates the present date and time and displays it in the present_datetime div.

Method 5: Using a Plugin for Enhanced Functionality

If you need updated attributes or customization, consider using a famous plugin. Here are some famous plugins for showing the current date and time:

  1. WP Date and Time Shortcode: This plugin provides shortcodes and widgets to show the present date and time in various formats.
  2. Time and Date Widget: Offers customizable options for showing time and date in various ways.
  3. Simple Custom Post Order: Incorporates date and time features as part of its post management functionalities.

1. Install and Activate a Plugin

  1. Go to Plugins > Add New in your WordPress dashboard.
  2. Explore the plugin you want to use.
  3. Install the plugin and activate it.

2. Configure the Plugin Settings

  1. Go to the plugin’s settings page.
  2. Customize the current date and time format according to your needs.
  3. Use the delivered shortcodes or widgets to show the present date and time on your site.

Conclusion

Showing the present date and time on your WordPress site can increase user experience and keep your content relevant. Whether you select to use shortcodes, widgets, PHP code, JavaScript, or plugins, there’s a solution that fits your needs. By incorporating one or more of these ways, you can ensure that your visitors always have up-to-date information at their fingertips.

Feel free to experiment with these techniques to find the best solution for your WordPress site. Keeping your site current not only assists engage your visitors but also demonstrates that your content is fresh and relevant. If you have any questions or need further assistance, don’t hesitate to reach out in the comments below!

Thanks for reading our article.
Developer at WPCarePoint
Booking for 30m Free Consultation on Google Meeting: Click here for an appointment today.
contact@wpcarepoint.com
www.wpcarepoint.com

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X

Like this:

Like Loading...

Related

Date and Time Plugins shortcodes WordPress WP Website
Shannon Brookes

    Related Posts

    How to Design a WordPress Website from Scratch?

    Elementor Updated:June 25, 20256 Mins Read

    Responsive Design for WordPress Site | wpcarepoint

    Web Development Updated:June 16, 20251 Min Read

    Top Web Design Services for Every Business in 2025| wpcarepoint

    Web Development Updated:May 30, 20254 Mins Read
    Leave A Reply Cancel Reply

    Don't Miss
    Elementor
    Elementor Updated:June 25, 20256 Mins Read

    How to Design a WordPress Website from Scratch?

    By rakibul0

    How to Design a WordPress Website from Scratch? In today’s digital world, having a website…

    Share this:

    • Click to share on Facebook (Opens in new window) Facebook
    • Click to share on X (Opens in new window) X

    Like this:

    Like Loading...

    Responsive Design for WordPress Site | wpcarepoint

    June 16, 2025

    Responsive Design for WordPress Site | wpcarepoint

    June 16, 2025

    Top Web Design Services for Every Business in 2025| wpcarepoint

    May 30, 2025

    WordPress Design Ideas for Any Website | wpcarepoint

    May 28, 2025
    Load More
    Our Picks

    How to Design a WordPress Website from Scratch?

    June 25, 2025

    Responsive Design for WordPress Site | wpcarepoint

    June 16, 2025

    Responsive Design for WordPress Site | wpcarepoint

    June 16, 2025

    Top Web Design Services for Every Business in 2025| wpcarepoint

    May 30, 2025

    Subscribe to Updates

    Get the latest creative news from WordPress Care Point about update on WordPress

    About Us

    We're accepting new partnerships right now.

    Email Us: contact@wpcarepoint.com
    Contact: +880 1611120080

    Facebook X (Twitter) Instagram LinkedIn WhatsApp
    Our Picks
    New Comments
    • CK on How to Create a Successful Your First Blog Post in 10 Easy Steps
    • Anonymous on How to Create a Successful Your First Blog Post in 10 Easy Steps
    WordPress Care Point
    Facebook LinkedIn Telegram
    © 2025 WordPreess Care Point. Developed by HirensPoint

    Type above and press Enter to search. Press Esc to cancel.

    Sign In or Register

    Welcome Back!

    Login to your account below.

    Security Code:

    Lost password?
    %d