PHP Knowledge Base
PHP date format
characters
Day
format character | Example returned values | Description |
---|---|---|
d | 01 to 31 | Day of the month, 2 digits with leading zeros |
D | Mon through Sun | A textual representation of a day, three letters |
j | 1 to 31 | Day of the month without leading zeros |
l (lowercase 'L') | Sunday through Saturday | A full textual representation of the day of the week |
N | 1 (for Monday) through 7 (for Sunday) | ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) |
S | st, nd, rd or th. Works well with j | English ordinal suffix for the day of the month, 2 characters |
w | 0 (for Sunday) through 6 (for Saturday) | Numeric representation of the day of the week |
z | 0 through 365 | The day of the year (starting from 0) |
Week
format character | Example returned values | Description |
---|---|---|
W | Example: 42 (the 42nd week in the year) | ISO-8601 week number of year, weeks starting on Monday |
Month
format character | Example returned values | Description |
---|---|---|
F | January through December | A full textual representation of a month |
m | 01 through 12 | Numeric representation of a month, with leading zeros |
M | Jan through Dec | A short textual representation of a month, three letters |
n | 1 through 12 | Numeric representation of a month, without leading zeros |
t | 28 through 31 | Number of days in the given month |
Year
format character | Example returned values | Description |
---|---|---|
L | 1 if it is a leap year, 0 otherwise. | Whether it's a leap year |
o | Examples: 1999 or 2003 | ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0) |
Y | Examples: 1999 or 2003 | A full numeric representation of a year, 4 digits |
y | Examples: 99 or 03 | A two digit representation of a year |