Managing Timezone, Date, and Format Preferences

Desmond Teh

Last Update il y a 2 mois

WordPress has built-in functions allowing users and developers to format dates and times. You can change the date and time format by navigating to Settings → General page from your WordPress dashboard. 


Scroll down to find Timezone, Date Format & Time Format sections. You can then change the date and time format as per your preferences. Let’s look at each of the sections in detail.

Timezone

You can start by typing in the city’s name and then choosing from the results in the dropdown menu.

Alternatively, you can set the UTC time zone, as shown below.

Date Format

You’ll notice the Date Format settings just below the Timezone settings. You can select the date format per your preference or even set a custom date.

To set a custom date, click the Custom radio button and enter the format you wish to set. For instance, we set a custom date as shown below.

Check the preview to ensure you chose the correct format. If you use punctuation marks like commas or dashes, note that they’ll be used everywhere.

Time Format

Next, you can set the time format located just under the date format settings.

Again, you can choose from one of the existing options or click on the Custom option to define your own. You can preview the selected format below.

You can also set the starting day of the week by selecting the day from the drop-down menu, as shown above.

Once you’ve made changes, click on the Save Changes button. And that’s how you can quickly change the date and time format in your WordPress site.

WordPress Time and Date Formats

There is a string of characters known as the format string next to each option for Date Format and Time Format on the Settings’ General page.

These format characters represent different elements of the date and time structure. Here is an illustration of what each character in the m/d/Y format string denotes:

  • m – the numeric month with a leading zero.
  • d – the numeric day of the month with a leading zero.
  • Y – the four-digit year.

Therefore, this string will output:

04/10/2024

You can also create your own custom structure string using the following date and time format characters.

Pattern DisplayExample
Month
FThe month’s full name January – December
M The month’s three-letter abbreviation Jan – Dec
mThe numeric month with leading zeros 01 – 12
nThe numeric month without leading zeros 1 – 12
Day of the month
dThe numeric day of the month with leading zeros01 – 31
jThe numeric day of the month without leading zeros 1 – 31
sThe English suffix for the numeric day of the month st (in 1st), nd (in 2nd)
Day of the week
l (lower-case letter L)The day of the week’s full name Monday – Sunday
D The day of the week’s three-letter abbreviation Mon – Sun
Year
Y The four-digit year 2024
yThe two-digit year22
Time
a Lowercase am or pm am, pm
AUppercase AM or PMAM, PM
g The hour in a 12-hour format without leading zeros 1 – 12
h The hour in a 12-hour format with leading zeros 01 – 12
G The hour in a 24-hour format without leading zeros 0 – 23
HThe hour in a 24-hour format with leading zeros 0 – 23
iMinutes with leading zeros00 – 59
s Seconds with leading zeros00 – 59
tThe timezone abbreviation PST, EDT
Full date and time
c ISO 8601 format 2022-10-29T18:56:24+00:00
rRFC 2822 formatMon, 04 April 2024 18:56:24+0200
UUnix Timestamp (seconds since the Unix epoch, January 1, 1970 00:00:00 GMT)1661842310

Examples of Time and Date Format Strings

Some examples of commonly used date and time format characters are as follows:

  • M d, Y – will output – Apr 04, 2024
  • d M, Y – will output – 04 Apr, 2024
  • F jS, Y – will output – April 4th, 2024
  • l, F jS, Y – will output – Monday, April 4th, 2024
  • H:i:s – will output – 21:24:12
  • F j, Y g: i a – will output – April 4, 2024 10:45 am

Was this article helpful?

0 out of 0 liked this article

Still need help? Message Us