C / POSIX strftime tokens.
The ancestor vocabulary — Python, Ruby and PHP's strftime, and most C descendants, all started from this table.
This is where the percent vocabulary began, and it is strictly padded: every numeric field has a fixed width and there is no portable unpadded form (glibc's %-d and BSD's %e-style tweaks are extensions, not POSIX). Names (%a %b %p) come from the current locale. %s (unix seconds) is not in this edition — it is a common extension that only became standard later. Week numbers come in three flavors (%U Sunday-first, %W Monday-first, %V ISO) that disagree around New Year; only %V pairs correctly with %G.
| Token | Means | Example |
|---|---|---|
| %Y | Four-digit year No fixed width — just the year as a decimal number. | 2006 |
| %y | Two-digit year | 06 |
| %m | Month number, padded | 01 |
| %b | Month name, abbreviated %h is defined as an exact equivalent. | Jan |
| %B | Month name, full | January |
| %d | Day of month, padded %e gives the space-padded day instead. | 02 |
| %a | Weekday, abbreviated | Mon |
| %A | Weekday, full | Monday |
| %j | Day of year Zero-padded to three digits [001,366]. | 2 |
| %V | Week of year ISO-8601 week [01,53]. %U (Sunday-first) and %W (Monday-first) count from 00 and disagree with it around New Year. | 1 |
| %G | ISO week-based year Pairs with %V; %g is its two-digit form. Using %Y next to %V is the classic New-Year bug. | 2006 |
| %H | Hour, 24-hour clock, padded | 15 |
| %I | Hour, 12-hour clock, padded | 03 |
| %p | AM/PM marker The locale's equivalent of a.m./p.m. — can be empty in locales without day periods. | PM |
| %M | Minute, padded | 04 |
| %S | Second, padded Range is [00,60] — 60 allows for leap seconds. | 05 |
| %z | UTC offset, basic +hhmm or -hhmm; no bytes at all if no timezone is determinable. | -0700 |
| %Z | Time-zone name, short Name or abbreviation; no bytes if no timezone information exists. | MST |
Examples render the reference instant, Mon, Jan 2 2006, 3:04:05 PM MST.
Literal text
A literal percent sign is written %%. Everything else passes through unchanged; an unlisted %-sequence is undefined behavior, so never rely on one.
Verified against POSIX.1-2017 (Issue 7) — strftime.