Table of Contents
Why do you display today's date in WordPress?
Method 1: Display today's date by adding code to the template file
Method 2: Use the shortcode to display today's date anywhere (recommended)
Home CMS Tutorial WordPress How to display today's date in WordPress (2 easy ways)

How to display today's date in WordPress (2 easy ways)

Apr 20, 2025 am 07:27 AM
wordpress geographical location Why 2025

Do 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.

How to display today's date in WordPress (2 easy ways)

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.

How to display today's date in WordPress (2 easy ways)

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:

  1. Show today's date by adding code to the template file
  2. 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:

How to display today's date in WordPress (2 easy ways)

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.

How to display today's date in WordPress (2 easy ways)

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.

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):

How to display today's date in WordPress (2 easy ways)

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']

How to display today's date in WordPress (2 easy ways)

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Which three major U.S. stock index futures rise Which three major U.S. stock index futures rise Apr 21, 2025 am 07:48 AM

On April 8, 2025, the three major U.S. stock index futures all rose. The specific situation is: 1. Dow futures rose 2%; 2. S&P 500 futures rose 1.78%; 3. Nasdaq futures rose 1.75%.

Top 11 list of Bitcoin Exchange Rate Conversion Global (Updated in 2025) Top 11 list of Bitcoin Exchange Rate Conversion Global (Updated in 2025) Apr 21, 2025 am 11:27 AM

The exchange rate of Bitcoin to currencies of various countries is as follows: 1. USD: at 7:20 on April 9, the exchange rate is 10,152.53. 2. Domestic: at 2:2 on April 9, 1 Bitcoin = 149,688.2954 yuan. 3. Swedish Krona: At 12:30 on April 9, the exchange rate was 758,541.05.

How to avoid losses after ETH upgrade How to avoid losses after ETH upgrade Apr 21, 2025 am 10:03 AM

After ETH upgrade, novices should adopt the following strategies to avoid losses: 1. Do their homework and understand the basic knowledge and upgrade content of ETH; 2. Control positions, test the waters in small amounts and diversify investment; 3. Make a trading plan, clarify goals and set stop loss points; 4. Profil rationally and avoid emotional decision-making; 5. Choose a formal and reliable trading platform; 6. Consider long-term holding to avoid the impact of short-term fluctuations.

Litecoin (LTC) price drops sharply to $65 Litecoin (LTC) price drops sharply to $65 Apr 21, 2025 pm 06:15 PM

Litecoin (LTC) price plummeted to $65 in early April, down nearly 7.5% in a week, echoing the plunge in the wider cryptocurrency market. The market crash caused billions of dollars to evaporate market value, Bitcoin (BTC) fell below $75,000, and altcoins generally fell. Macro factors such as rising U.S. Treasury yields and expected interest rates appear to intensify risk aversion in global markets. In addition, the large outflow of funds from Bitcoin spot ETFs further hits the confidence of retail investors and institutional investors. Against this backdrop, Litecoin is once again facing its long-term resistance level - the 200-week exponential moving average (EMA). The EMA had suppressed LTC prices in July 2023, when the price was close to $88. Historically, LTC and the

Ranking of legal platform apps for virtual currency trading Ranking of legal platform apps for virtual currency trading Apr 21, 2025 am 09:27 AM

This article lists the ranking of APPs for legal platforms for virtual currency transactions, emphasizing that compliance is an important consideration for choosing a platform. The article recommends platforms such as Coinbase, Gemini, and Kraken, and reminds investors to study regulatory information and pay attention to security records when making choices. At the same time, the article emphasizes that virtual currency transactions are high-risk and investments should be cautious.

What to do if the USDT transfer address is incorrect? Guide for beginners What to do if the USDT transfer address is incorrect? Guide for beginners Apr 21, 2025 pm 12:12 PM

After the USDT transfer address is incorrect, first confirm that the transfer has occurred, and then take measures according to the error type. 1. Confirm the transfer: view the transaction history, obtain and query the transaction hash value on the blockchain browser. 2. Take measures: If the address does not exist, wait for the funds to be returned or contact customer service; if it is an invalid address, contact customer service and seek professional help; if it is transferred to someone else, try to contact the payee or seek legal help.

Rexas Finance (RXS) can surpass Solana (Sol), Cardano (ADA), XRP and Dogecoin (Doge) in 2025 Rexas Finance (RXS) can surpass Solana (Sol), Cardano (ADA), XRP and Dogecoin (Doge) in 2025 Apr 21, 2025 pm 02:30 PM

In the volatile cryptocurrency market, investors are looking for alternatives that go beyond popular currencies. Although well-known cryptocurrencies such as Solana (SOL), Cardano (ADA), XRP and Dogecoin (DOGE) also face challenges such as market sentiment, regulatory uncertainty and scalability. However, a new emerging project, RexasFinance (RXS), is emerging. It does not rely on celebrity effects or hype, but focuses on combining real-world assets (RWA) with blockchain technology to provide investors with an innovative way to invest. This strategy makes it hoped to be one of the most successful projects of 2025. RexasFi

WorldCoin (WLD) price forecast 2025-2031: Will WLD reach USD 4 by 2031? WorldCoin (WLD) price forecast 2025-2031: Will WLD reach USD 4 by 2031? Apr 21, 2025 pm 02:42 PM

WorldCoin (WLD) stands out in the cryptocurrency market with its unique biometric verification and privacy protection mechanisms, attracting the attention of many investors. WLD has performed outstandingly among altcoins with its innovative technologies, especially in combination with OpenAI artificial intelligence technology. But how will the digital assets behave in the next few years? Let's predict the future price of WLD together. The 2025 WLD price forecast is expected to achieve significant growth in WLD in 2025. Market analysis shows that the average WLD price may reach $1.31, with a maximum of $1.36. However, in a bear market, the price may fall to around $0.55. This growth expectation is mainly due to WorldCoin2.

See all articles