WordPress comes with built-in function of date and time format from where user as well as developer can use it. You can easily modify your format by clicking to, Settings » General:

Screenshot WordPress dashboard Settings -> General -> Date Time Format

WordPress offers you a variety of pre-defined formats that you can choose to use, as well as allowing you to add a custom format of your choice.

The date and time format are based alphabetic characters that represent a time format. For example, entering Y will output the year in numeric four digits, like 2017 or – d will output the Date in numeric two digits with leading zeros, like 0-31. Entering j will output the Date in numeric two digits without leading zero like 1-31.

All the available format characters have been divided into sections to make things easier when it comes to finding the character you’re looking for. Here is a selection of the most commonly used format characters.:

Hour

h – The hour of the day using two digits, such as 01, 05, 11.
H – The hour of the day using two digits, in 24-hour format, such as 07, 13, 22.
g – The hour of the day using up to two digits, such as 3, 8, 12.
G – The hour of the day using up to two digits, in 24-hour format, such as 00, 15, 21.
A – Displays either Ante meridiem and Post meridiem using uppercase letters, such as AM or PM.
a – Displays either Ante meridiem and Post meridiem using lowercase letters, such as am or pm.

Minute

i – The minute of the hour using two digits, such as 05, 32, 59.

Second

s – The second of the minute using two digits, such as 01, 48, 51.

Timezone

e – The timezone identifier in full, such as Europe/Berlin, America/New York.
T – The timezone identifier abbreviated, such as EST, GMT, MDT.
O – Difference, in hours, to the GMT timezone, such as +0100, +0530, +0800.
P – Difference, in hours, to the GMT timezone, colon separated, such as +02:00, +04:00, +07:30.

Day

d – Day of the month using two digits, such as 01, 18, 31.
j – Day of the month using up to two digits, such as 1, 8, 24.
S – Display ordinal indicators, such as st, nd, rd, or th.
D – Day of the month using three letters, such as Mon, Wed, Sun.
l – Day of the month in full, such as Monday, Thursday, Saturday.

Month

m – Month of the year using two digits, such as 01, 07, 11.
n – Month of the year using up to two digits, such as 2, 9, 12.
M – Month of the year using three letters, such as Mar, Aug, Nov.
F – Month of the year in full, such as January, May, October.

Year

y – The year using two digits, such as 97, 03, 17.
Y – The year in full, such as 1984, 2001, 2017.


Using the above listed format characters , you can easily customize the date and time output throughout your entire WordPress website to always show your preferred formats. For more details you can consult the documentation within the WordPress Codex.