PHP date() tokens.
DateTime::format(), Carbon
Every token is a single bare letter, so case is the whole vocabulary: m and M, h and H, and the easily confused l (weekday name) versus L (leap year) mean different things. Names always render in English — like Go, there is no locale support here. The famous trap is z, the day of year: it starts from 0, so January 1 is day 0 and it runs one behind every other language's day-of-year; it is deliberately left unmapped below. Sub-second tokens (v, u) only produce real digits from a DateTime object — date() itself takes an integer timestamp and always prints zeros. No era or quarter tokens; BCE years just get a minus sign from Y.
| Token | Means | Example |
|---|---|---|
| Y | Four-digit year At least four digits; years BCE get a leading minus sign. | 2006 |
| y | Two-digit year | 06 |
| n | Month number | 1 |
| m | Month number, padded | 01 |
| M | Month name, abbreviated | Jan |
| F | Month name, full | January |
| j | Day of month | 2 |
| d | Day of month, padded | 02 |
| D | Weekday, abbreviated | Mon |
| l | Weekday, full Lowercase L. For numeric weekdays, N gives ISO 1 (Monday) to 7 and w gives 0 (Sunday) to 6. | Monday |
| W | Week of year ISO-8601 week, Monday start, zero-padded to two digits (the manual's example 42 hides the padding). Pairs with o, not Y. | 1 |
| o | ISO week-based year Same as Y except around New Year, when the ISO week belongs to the neighbouring year. | 2006 |
| G | Hour, 24-hour clock | 15 |
| H | Hour, 24-hour clock, padded | 15 |
| g | Hour, 12-hour clock | 3 |
| h | Hour, 12-hour clock, padded | 03 |
| A | AM/PM marker Uppercase AM/PM; lowercase a gives am/pm. | PM |
| i | Minute, padded | 04 |
| s | Second, padded | 05 |
| v | Fractional seconds Exactly three digits (milliseconds); u gives six (microseconds). Real digits require a DateTime object — date() always prints zeros. | 000 |
| O | UTC offset, basic | -0700 |
| P | UTC offset, extended p (PHP 8.0+) is identical but prints Z instead of +00:00. | -07:00 |
| T | Time-zone name, short Falls back to a GMT offset like +05 when no abbreviation is known; e gives the full identifier (Atlantic/Azores). | MST |
| U | Unix timestamp | 1136239445 |
Examples render the reference instant, Mon, Jan 2 2006, 3:04:05 PM MST.
Literal text
Escape a recognized letter with a preceding backslash, e.g. \j. Inside double-quoted PHP strings the backslash itself may need doubling ("\\t") because \t is already an escape sequence — single-quoted format strings avoid the problem.
Verified against PHP manual — DateTimeInterface::format() format characters.