PHP Knowledge Base

PHP date format characters

Day

format characterExample returned valuesDescription
d01 to 31Day of the month, 2 digits with leading zeros
DMon through SunA textual representation of a day, three letters
j1 to 31Day of the month without leading zeros
l (lowercase 'L')Sunday through SaturdayA full textual representation of the day of the week
N1 (for Monday) through 7 (for Sunday)ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0)
Sst, nd, rd or th. Works well with jEnglish ordinal suffix for the day of the month, 2 characters
w0 (for Sunday) through 6 (for Saturday)Numeric representation of the day of the week
z0 through 365The day of the year (starting from 0)

Week

format characterExample returned valuesDescription
WExample: 42 (the 42nd week in the year)ISO-8601 week number of year, weeks starting on Monday

Month

format characterExample returned valuesDescription
FJanuary through DecemberA full textual representation of a month
m01 through 12Numeric representation of a month, with leading zeros
MJan through DecA short textual representation of a month, three letters
n1 through 12Numeric representation of a month, without leading zeros
t28 through 31Number of days in the given month

Year

format characterExample returned valuesDescription
L1 if it is a leap year, 0 otherwise.Whether it's a leap year
oExamples: 1999 or 2003ISO-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)
YExamples: 1999 or 2003A full numeric representation of a year, 4 digits
yExamples: 99 or 03A two digit representation of a year