PHP time format controller Table share
- 2020-07-21 07:15:23
- OfStack
format character
instructions
Return value example
day
---
---
d
On the day of the month, a two-digit number with a leading zero
01 to 31
j
Day of the month, no leading zero
1 to 31
S
Days of the month after the English suffix, 2 characters
st, nd, rd or th. It works with j 1
z
Day of the year
0 to 366
week
---
---
l (lowercase letters of "L")
Day of the week, full text format
Sunday to Saturday
D
The day of the week, the text is three letters
Mon to Sun
N
Day of the Week in ISO-8601 format (PHP 5.1.0 added)
1 (for Monday) to 7 (for Sunday)
w
The number of days of the week
0 (for Sunday) to 6 (for Saturday)
W
Week of the year in ISO-8601 format, each week commencing on Monday (new addition to PHP 4.1.0)
Example: 42 (week 42 of the year)
month
---
---
F
Month, full text format, such as January or March
January to December
m
The number represents the month, with leading zeros
01 to 12
M
A month with three initials
Jan to Dec
n
The number represents the month, with no leading zero
1 to 12
t
The number of days due in a given month
28 to 31
years
---
---
L
Is it a leap year
If it's a leap year, it's 1, otherwise it's 0
o
Year number in ISO-8601 format. This is the same value as Y, except that if the number of weeks of ISO (W) belongs to the previous or next year, that year is used. (PHP 5.1.0 added)
Examples: 1999 or 2003
Y
The full year represented by four digits
For example: 1999 or 2003
y
The year is represented by two digits
For example: 99 or 03
time
---
---
a
Lower case morning and afternoon values
am or pm
A
Capitalize the morning and afternoon values
AM or PM
B
Swatch Internet standard time
From 000 to 999
g
Hour, 12 hour format, no leading zero
1 to 12
G
Hours, 24 hour format, no leading zero
0 to 23
h
Hour, 12 hour format, with leading zeros
01 to 12
H
Hours, 24 hour format, with leading zeros
00 to 23
i
The number of minutes with leading zeros
00 to 59
>
s
Number of seconds, leading zeros
00 to 59
>
The time zone
---
---
e
Time zone identification (PHP 5.1.0 added)
Examples: UTC, GMT, Atlantic/Azores
I
Daylight saving time or not
If daylight saving time is 1, otherwise it's 0
O
The number of hours out of Greenwich mean time
For example: + 0200
P
Different from GMT (GMT), there is a colon separator between hours and minutes (PHP 5.1.3 plus)
For example: + 2:00
T
The time zone in which the machine is located
For example: EST, MDT (Eastern Standard Time)
Z
The number of seconds of moveout offset. The western time zone offset of UTC is always negative and the eastern time zone offset of UTC is always positive.
43200 to 43200
Full date/time
---
---
c
Date in ISO 8601 format (PHP 5 added)
2004-02-12T15:19:21+00:00
r
Date in RFC 822 format
For example, Thu, 21 Dec 2000 16:01:07 +0200
U
The number of seconds since the Unix era (January 1 1970 00:00:00 GMT) is the time stamp
See time ()