How to display today's date in WordPress (2 easy ways)
Apr 20, 2025 am 07:27 AMDo you want to display today's date in WordPress?
Many news websites, online journals, and frequently updated blogs may want to show the current date and time. This allows users to know the current date and when the content was published.
In this article, we will show you how to easily display today's date or current time on your WordPress website.
Why do you display today's date in WordPress?
Many news sites display current dates in the title section of their website, especially small news sites that publish their main stories every day.
This assures the user that they are viewing the latest version of the online version of the publication. This is a useful style decision, and many news sites are still in use, although the homepage is updated several times a day.
Similarly, online journals and bloggers have adopted this style. This ensures that the user is viewing the latest entries on the blog.
In other usage scenarios, you may want to display only the current date and time.
For example, if your live chat is taking place at a specific time and you want to show the customer the time you are in your geographic location. Alternatively, you are running a countdown timer activity and want to display the current date to create a stronger FOMO effect.
That being said, let's see how to easily display today's date, day of the week, or current time on your WordPress website. We will introduce two methods:
- Show today's date by adding code to the template file
- Use a shortcode to display today's date anywhere
Method 1: Display today's date by adding code to the template file
WordPress does not come with a default widget or block to display the current date or time.
However, you can still use some very simple code to display the current date or time.
You can add this simple code to the template file for the WordPress theme you want to display time:
You can also use your own format tag to output dates in any other format. For example, using the following code, you can print dates in month, day, year formats.
This approach allows you to add code directly to your WordPress theme file, but is not very flexible. What if you want to display the current date and time in a WordPress post, page, or sidebar widget?
The next method allows you to add dates and times anywhere on your website.
Method 2: Use the shortcode to display today's date anywhere (recommended)
For this method, we will create a short code and then use it to display the date and time anywhere on the WordPress website.
You can add the following code to the theme's functions.php file, or use a custom code snippet plugin, such as WPCode (recommended):
This code just creates a short code that displays the current date. You can use it by adding this shortcode anywhere on the website:
[date-today]
By default, the shortcode displays the date in the default date format in WordPress settings.
You can also use your own date format by modifying the shortcode as follows:
[date-today format='F j, Y']
We hope this article helps you understand how to easily display today's dates in WordPress. You may also want to check out our guide on how to add weather forecasts in WordPress, or our expertly selected Best Quiz Plugins for WordPress.
The above is the detailed content of How to display today's date in WordPress (2 easy ways). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

?In today's increasingly popular digital asset trading, it is particularly important to understand how to safely and effectively withdraw your digital assets. As a world-renowned digital asset trading platform, ok exchange provides convenient currency withdrawal services. This tutorial will analyze in detail the steps of withdrawing coins on the ok exchange, things to note, and some common questions and answers to help users complete asset transfer smoothly and ensure asset security. Whether you are using ok exchange for withdrawals for the first time or want to further understand the withdrawal process, this article will provide you with clear and practical guidance.

The latest version of Digital Currency Exchange 2025 is a world-leading digital asset trading application, committed to providing users with secure, stable and convenient trading services for mainstream digital currencies such as Bitcoin and Ethereum. Its simple and intuitive operation interface and powerful functional modules make it easy for both novices and senior traders to get started.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

As July 2025 approaches, the crypto market is hotly discussing which tokens may bring high returns. Are names like Pi, PEPE and FloppyPepe really worth the risky investment? Potential cryptocurrencies worth paying attention to in July 2025: virtual fire or real gold? As mid-2025, the heat of discussions on high-yield crypto assets continues to heat up. Bitcoin trends and "altcoin season" expectations have attracted investors' attention. Do tokens like PiNetwork, PEPE and FloppyPepe have the potential to bring considerable investment returns? Let's analyze its prospects one by one. Altcoin Market: Can July get what it wants? Against the backdrop of Bitcoin’s expected record of historical highs, the “altcoin season” seems to be brewing. Back

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest version of Binance is 2.101.8, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest version of Binance is 2.101.8, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.
