Developer Tool

strftime Format Cheatsheet

Every common strftime format code, with a live tester — type a format string and see exactly what it outputs, using the current moment.

Where this format-code convention comes from

strftime originated in C's standard library in the 1980s, and its %-prefixed codes have been copied nearly unchanged into Python, Ruby, PHP, Perl, R, and many others ever since — making it one of the longest-lived, most widely shared conventions in programming, even as the languages using it have almost nothing else in common.

A common gotcha: locale-dependent codes

%a, %A, %b, and %B (weekday and month names) render in whatever locale the running program is configured for — code tested on a US-locale machine that outputs "Monday, June" can silently output something completely different once deployed to a server configured for another language, if the locale isn't set explicitly.

Related

Related tools