PHP/Development/date function

Материал из Web эксперт
Перейти к: навигация, поиск

Format Codes for Use with date()

Format                Description                                  Example
a                     "am" or "pm" lowercase                       pm
A                     "AM" or "PM" uppercase                       PM
d                     Day of month (number with leading zeroes)    20
D                     Day of week (three letters)                  Thu
F                     Month name                                   January
h                     Hour (12-hour format)                        12
H                     Hour (24-hour format)                        12
g                     Hour (12-hour format without leading 0)      12
G                     Hour (24-hour format without leading 0)      12
i                     Minutes                                      47
j                     Day of the month (no leading zeroes)         20
1                     Day of the week (name)                       Thursday
L                     Leap year ("1" for yes, "0" for no)          1
m                     Month of year (number)                       01
M                     Month of year (three letters)                Jan
n                     Month of year (number without leading 0)     1
s                     Seconds of hour                              24
U                     Time stamp                                   948372444
y                     Year (two digits)                            00
Y                     Year (four digits)                           2000
z                     Day of year (0?65)                           19
Z                     Offset in seconds from GMT                   0

Formatting a Date with date()

<title>Formatting a date with date()</title>
print date("m/d/y G.i:s<br>", time());
print "Today is ";
print date("j of F Y, \a\\t g.i a", time());