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.

TokenMeansExample
%YFour-digit year

No fixed width — just the year as a decimal number.

2006
%yTwo-digit year06
%mMonth number, padded01
%bMonth name, abbreviated

%h is defined as an exact equivalent.

Jan
%BMonth name, fullJanuary
%dDay of month, padded

%e gives the space-padded day instead.

02
%aWeekday, abbreviatedMon
%AWeekday, fullMonday
%jDay of year

Zero-padded to three digits [001,366].

2
%VWeek 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
%GISO week-based year

Pairs with %V; %g is its two-digit form. Using %Y next to %V is the classic New-Year bug.

2006
%HHour, 24-hour clock, padded15
%IHour, 12-hour clock, padded03
%pAM/PM marker

The locale's equivalent of a.m./p.m. — can be empty in locales without day periods.

PM
%MMinute, padded04
%SSecond, padded

Range is [00,60] — 60 allows for leap seconds.

05
%zUTC offset, basic

+hhmm or -hhmm; no bytes at all if no timezone is determinable.

-0700
%ZTime-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.

Translate C / POSIX strftime