PHP TUTORIALS - PHP Date & Time
PHP Date & Time
ADVERTISEMENTS
Getting the Time Stamp with time():
|
ADVERTISEMENTS
|
ADVERTISEMENTS
Converting a Time Stamp with getdate():
Key | Description | Example |
---|---|---|
seconds | Seconds past the minutes (0-59) | 20 |
minutes | Minutes past the hour (0 - 59) | 29 |
hours | Hours of the day (0 - 23) | 22 |
mday | Day of the month (1 - 31) | 11 |
wday | Day of the week (0 - 6) | 4 |
mon | Month of the year (1 - 12) | 7 |
year | Year (4 digits) | 1997 |
yday | Day of year ( 0 - 365 ) | 19 |
weekday | Day of the week | Thursday |
month | Month of the year | January |
0 | Timestamp | 948370048 |
Example:
|
|
Converting a Time Stamp with date():
|
Format | Description | Example |
---|---|---|
a | 'am' or 'pm' lowercase | pm |
A | 'AM' or 'PM' uppercase | PM |
d | Day of month, a number with leading zeroes | 20 |
D | Day of week (three letters) | Thu |
F | Month name | January |
h | Hour (12-hour format - leading zeroes) | 12 |
H | Hour (24-hour format - leading zeroes) | 22 |
g | Hour (12-hour format - no leading zeroes) | 12 |
G | Hour (24-hour format - no leading zeroes) | 22 |
i | Minutes ( 0 - 59 ) | 23 |
j | Day of the month (no leading zeroes | 20 |
l (Lower 'L') | Day of the week | Thursday |
L | Leap year ('1' for yes, '0' for no) | 1 |
m | Month of year (number - leading zeroes) | 1 |
M | Month of year (three letters) | Jan |
r | The RFC 2822 formatted date | Thu, 21 Dec 2000 16:01:07 +0200 |
n | Month of year (number - no leading zeroes) | 2 |
s | Seconds of hour | 20 |
U | Time stamp | 948372444 |
y | Year (two digits) | 06 |
Y | Year (four digits) | 2006 |
z | Day of year (0 - 365) | 206 |
Z | Offset in seconds from GMT | +5 |
Example:
|
|