Quick reference

strftime Formatting Cheatsheet

Quick reference guide for UNIX strftime date and time format specifiers, compatible with C, Python, Ruby, and POSIX shell utilities.

· Published

The strftime format standard defines date and time formatting specifiers across POSIX systems, C, Ruby, Python, and command-line utilities like date.

Common Presets

Date Patterns

Format Specifier Sample Output Description
%m/%d/%Y 06/05/2026 US standard date
%A, %B %e, %Y Sunday, June 5, 2026 Long full date
%b %e %a Jun 5 Sun Short date
%Y-%m-%d 2026-06-05 ISO 8601 date

Time Patterns

Format Specifier Sample Output Description
%H:%M 23:05 24-hour time without seconds
%I:%M %p 11:05 PM 12-hour time with AM/PM
%H:%M:%S 23:05:42 24-hour time with seconds

Date Specifiers

Specifier Example Description
%a Sun Abbreviated weekday name
%A Sunday Full weekday name
%w 0..6 Weekday as decimal (0 = Sunday)
%u 1..7 Weekday as decimal (1 = Monday)
%y 26 Two-digit year
%Y 2026 Four-digit year
%b Jan Abbreviated month name
%B January Full month name
%m 01..12 Month as zero-padded decimal
%d 01..31 Day of the month zero-padded
%e 1..31 Day of the month blank-padded

Time Specifiers

Specifier Example Description
%l 1 Hour in 12-hour clock blank-padded (1..12)
%H 00..23 Hour in 24-hour clock zero-padded
%I 01..12 Hour in 12-hour clock zero-padded
%M 00..59 Minute as zero-padded decimal
%S 00..60 Second as zero-padded decimal
%p AM / PM Meridian indicator
%z +0000 RFC 822 / ISO 8601 numeric timezone offset
%Z UTC Timezone abbreviation name
%j 001..366 Day of the year as zero-padded decimal
%% % Literal percentage sign

Related topics