ptg10805159
Section 6.10 Time and Date Routines 193
functions, each conversion specified generates a different fixed-size output
string — thereare nofield widths in theformatstring. Figure6.10 describes the 37 ISO C
conversion specifiers.
Format Description Example
%a abbreviated weekday name Thu
%A full weekday name Thursday
%b abbreviated month name Jan
%B full month name January
%c date and time Thu Jan 19 21:24:52 2012
%C year/100: [00–99] 20
%d day of the month: [01–31] 19
%D date[MM/DD/YY] 01/19/12
%e day of month (single digit preceded by space) [1–31] 19
%F ISO 8601 date format [YYYY–MM–DD] 2012 - 01 - 19
%g last two digits of ISO 8601 week-based year [00–99] 12
%G ISO 8601 week-based year 2012
%h same as%b Jan
%H hour of the day (24-hour format): [00–23] 21
%I hour of the day (12-hour format): [01–12] 09
%j day of the year: [001–366] 019
%m month: [01–12] 01
%M minute: [00–59] 24
%n newline character
%p AM/PM PM
%r locale’s time (12-hour format) 09:24:52 PM
%R same as%H:%M 21:24
%S second: [00–60] 52
%t horizontal tab character
%T same as%H:%M:%S 21:24:52
%u ISO 8601 weekday [Monday = 1, 1–7] 4
%U Sunday week number: [00–53] 03
%V ISO 8601 week number: [01–53] 03
%w weekday: [0 = Sunday,0–6] 4
%W Monday week number: [00–53] 03
%x locale’s date 01/19/12
%X locale’s time 21:24:52
%y last two digits of year: [00–99] 12
%Y year 2012
%z offset from UTC in ISO 8601 format -0500
%Z time zone name EST
%% translates to a percent sign %
Figure 6.10 Conversion specifiers forstrftime
The thirdcolumn of this figure is fromthe output ofstrftimeunder Mac OS X,
corresponding to the time and dateThu Jan 19 21:24:52 EST 2012.
The only specifiers that arenot self-evident are%U,%V,and%W.The%Uspecifier
represents the week number of the year,wherethe week containing the first Sunday is
week 1. The%Wspecifier represents the week number of the year,wherethe week
containing the first Monday is week 1. The%Vspecifier is different. If the week