Date format tokens
There are two widely used families of date format strings and they overlap just enough to be dangerous. strftime — from C, and inherited by Python, Ruby, PHP and GNU date — uses percent tokens like %Y. Unicode LDML, used by ICU, Java, moment and dayjs, uses repeated letters like yyyy. In LDML, MM is a month and mm is a minute; getting that pair backwards is the classic bug.
Every row below is rendered for the same instant: Monday 9 March 2026, 14:05:07 UTC. That date is chosen so nothing hides — a single-digit day and month expose zero-padding, the afternoon hour makes the 12- and 24-hour clocks differ visibly, and the weekday is unambiguous.
An empty equivalent column means the other dialect has no single token for it and you have to compose the value yourself. The test suite renders the calendar fields with the platform's own date functions and compares them to this table, so the examples cannot drift from reality.
Year
4| strftime | LDML | Field | Renders as |
|---|---|---|---|
| %Y | yyyy | Four-digit year | 2026 |
| %y | yy | Two-digit yearAmbiguous by construction. Avoid it in anything stored. | 26 |
| %C | Century — the year divided by 100 | 20 | |
| %G | YYYY | ISO week-numbering yearDiffers from the calendar year around New Year. Use with the ISO week number only. | 2026 |
Month
4In LDML, MM is the month and mm is the minute.
| strftime | LDML | Field | Renders as |
|---|---|---|---|
| %m | MM | Month, zero-padded | 03 |
| %-m | M | Month, no padding | 3 |
| %b | MMM | Abbreviated month name | Mar |
| %B | MMMM | Full month name | March |
Day and weekday
8In LDML, dd is day of month and DDD is day of year.
| strftime | LDML | Field | Renders as |
|---|---|---|---|
| %d | dd | Day of month, zero-padded | 09 |
| %-d | d | Day of month, no padding | 9 |
| %e | Day of month, space-padded | 9 | |
| %j | DDD | Day of year, 001–366 | 068 |
| %a | EEE | Abbreviated weekday name | Mon |
| %A | EEEE | Full weekday name | Monday |
| %u | Weekday as a number, Monday is 1%w numbers the same days from Sunday as 0. | 1 | |
| %V | ww | ISO week number, weeks starting Monday | 11 |
Time
8| strftime | LDML | Field | Renders as |
|---|---|---|---|
| %H | HH | Hour on the 24-hour clock | 14 |
| %-H | H | Hour, no padding | 14 |
| %I | hh | Hour on the 12-hour clock | 02 |
| %M | mm | Minute | 05 |
| %S | ss | Second | 07 |
| %3N | SSS | Milliseconds | 000 |
| %p | a | AM or PM | PM |
| %s | Unix timestamp — seconds since 1970-01-01 UTC | 1773065107 |
Time zone
3An offset is a number; a zone name is a rule. Only the name survives a DST change.
| strftime | LDML | Field | Renders as |
|---|---|---|---|
| %z | ZZ | UTC offset, no colon | +0000 |
| %:z | XXX | UTC offset with a colon, as ISO 8601 wants it | +00:00 |
| %Z | zzz | Time zone abbreviationAbbreviations are not unique — CST is at least three different zones. | UTC |
Common combinations
7Built out of the tokens above — no library needed.
| strftime | LDML | Field | Renders as |
|---|---|---|---|
| %F | yyyy-MM-dd | ISO date | 2026-03-09 |
| %T | HH:mm:ss | 24-hour time | 14:05:07 |
| %FT%T%:z | yyyy-MM-dd'T'HH:mm:ssXXX | Full ISO 8601 timestampThe format to store. Sorts as text, unambiguous about the offset. | 2026-03-09T14:05:07+00:00 |
| %a, %d %b %Y %T %z | EEE, dd MMM yyyy HH:mm:ss ZZ | RFC 2822 — email headers and older HTTP | Mon, 09 Mar 2026 14:05:07 +0000 |
| %m/%d/%Y | MM/dd/yyyy | US convention, month first | 03/09/2026 |
| %d.%m.%Y | dd.MM.yyyy | European convention, day first | 09.03.2026 |
| %% | '' | A literal percent sign | % |