Rust chrono tokens.
The de-facto Rust date-time crate
Chrono ships its own strftime implementation, so output is identical on every platform — and the padding overrides %-?, %_? and %0? are documented and portable, unlike their glibc-only cousins in Python. True unpadded tokens don't exist: %e, %k and %l are space-padded, which is not the same thing. The biggest trap is %f, which prints nanoseconds since the last whole second as a bare unscaled number — the dotted %.f family is what you almost always want. There is no era token, and %Z never prints a zone abbreviation.
| Token | Means | Example |
|---|---|---|
| %Y | Four-digit year Zero-padded to four digits; proleptic Gregorian, so negative years are possible. | 2006 |
| %y | Two-digit year Floor division: 100 BCE (year -99) prints 99, with %C giving -1. | 06 |
| %m | Month number, padded The documented %-m modifier form suppresses padding. | 01 |
| %b | Month name, abbreviated Always three letters; %h is a synonym. | Jan |
| %B | Month name, full Parsing also accepts the abbreviation. | January |
| %d | Day of month, padded %e is the space-padded day (same as %_d); %-d suppresses padding entirely. | 02 |
| %a | Weekday, abbreviated Always three letters. | Mon |
| %A | Weekday, full Parsing also accepts the abbreviation. | Monday |
| %j | Day of year Zero-padded to three digits (001–366). | 2 |
| %V | Week of year ISO-8601 week (01–53; week 0 does not exist). %U (Sunday-first) and %W (Monday-first) count from 00 and disagree around New Year. | 1 |
| %G | ISO week-based year Pairs with %V; mixing %Y with %V is the classic New-Year bug. %g is the two-digit form. | 2006 |
| %H | Hour, 24-hour clock, padded %k is the space-padded form (same as %_H); %-H suppresses padding. | 15 |
| %I | Hour, 12-hour clock, padded %l is the space-padded form (same as %_I). | 03 |
| %p | AM/PM marker Uppercase AM/PM; %P gives lowercase am/pm. | PM |
| %M | Minute, padded | 04 |
| %S | Second, padded Range is 00–60 because chrono accounts for leap seconds. | 05 |
| %.3f | Fractional seconds Milliseconds including the leading dot (.026); %.6f and %.9f fix other widths, %3f drops the dot. Bare %f is a trap — nanoseconds as an unscaled number. | 000 |
| %z | UTC offset, basic %#z is parsing-only and tolerates missing minutes. | -0700 |
| %:z | UTC offset, extended %::z adds seconds; %:::z drops minutes. | -07:00 |
| %Z | Time-zone name, short Trap: when formatting, this prints the offset, not a zone abbreviation — chrono only knows offsets. Parsing skips any non-whitespace. | MST |
| %s | Unix timestamp Seconds since 1970-01-01 00:00 UTC. | 1136239445 |
| %q | Quarter Single digit, 1–4. | 1 |
Examples render the reference instant, Mon, Jan 2 2006, 3:04:05 PM MST.
Literal text
A literal percent sign must be written %%; %t and %n produce a tab and a newline. Other text passes through literally, but an unrecognized %-sequence makes the whole format string invalid rather than passing through.
Verified against chrono docs — strftime format specifiers.