1 NEWSTRFTIME(3) NEWSTRFTIME(3)
4 strftime - format date and time
10 size_t strftime(buf, maxsize, format, timeptr)
14 const struct tm *timeptr
19 The strftime function formats the information from timeptr into the
20 buffer buf according to the string pointed to by format.
22 The format string consists of zero or more conversion specifications
23 and ordinary characters. All ordinary characters are copied directly
24 into the buffer. A conversion specification consists of a percent sign
25 and one other character.
27 No more than maxsize characters are be placed into the array. If the
28 total number of resulting characters, including the terminating null
29 character, is not more than maxsize, strftime returns the number of
30 characters in the array, not counting the terminating null. Otherwise,
33 Each conversion specification is replaced by the characters as follows
34 which are then copied into the buffer.
36 %A is replaced by the locale's full weekday name.
38 %a is replaced by the locale's abbreviated weekday name.
40 %B is replaced by the locale's full month name.
43 is replaced by the locale's abbreviated month name.
45 %C is replaced by the century (a year divided by 100 and truncated
46 to an integer) as a decimal number (00-99).
48 %c is replaced by the locale's appropriate date and time
51 %D is replaced by the date in the format %m/%d/%y.
53 %d is replaced by the day of the month as a decimal number (01-31).
55 %e is replaced by the day of month as a decimal number (1-31);
56 single digits are preceded by a blank.
58 %F is replaced by the date in the format %Y-%m-%d.
60 %G is replaced by the ISO 8601 year with century as a decimal
63 %g is replaced by the ISO 8601 year without century as a decimal
66 %H is replaced by the hour (24-hour clock) as a decimal number
69 %I is replaced by the hour (12-hour clock) as a decimal number
72 %j is replaced by the day of the year as a decimal number
75 %k is replaced by the hour (24-hour clock) as a decimal number
76 (0-23); single digits are preceded by a blank.
78 %l is replaced by the hour (12-hour clock) as a decimal number
79 (1-12); single digits are preceded by a blank.
81 %M is replaced by the minute as a decimal number (00-59).
83 %m is replaced by the month as a decimal number (01-12).
85 %n is replaced by a newline.
87 %p is replaced by the locale's equivalent of either AM or PM.
89 %R is replaced by the time in the format %H:%M.
91 %r is replaced by the locale's representation of 12-hour clock time
94 %S is replaced by the second as a decimal number (00-60).
96 %s is replaced by the number of seconds since the Epoch, UTC (see
99 %T is replaced by the time in the format %H:%M:%S.
101 %t is replaced by a tab.
103 %U is replaced by the week number of the year (Sunday as the first
104 day of the week) as a decimal number (00-53).
106 %u is replaced by the weekday (Monday as the first day of the week)
107 as a decimal number (1-7).
109 %V is replaced by the week number of the year (Monday as the first
110 day of the week) as a decimal number (01-53). If the week
111 containing January 1 has four or more days in the new year, then
112 it is week 1; otherwise it is week 53 of the previous year, and
113 the next week is week 1.
115 %W is replaced by the week number of the year (Monday as the first
116 day of the week) as a decimal number (00-53).
118 %w is replaced by the weekday (Sunday as the first day of the week)
119 as a decimal number (0-6).
121 %X is replaced by the locale's appropriate time representation.
123 %x is replaced by the locale's appropriate date representation.
125 %Y is replaced by the year with century as a decimal number.
127 %y is replaced by the year without century as a decimal number
130 %Z is replaced by the time zone name, or by the empty string if
131 this is not determinable.
133 %z is replaced by the offset from UTC in the format +HHMM or -HHMM
134 as appropriate, with positive values representing locations east
135 of Greenwich, or by the empty string if this is not
138 %% is replaced by a single %.
140 %+ is replaced by the date and time in date(1) format.
143 date(1), getenv(3), newctime(3), newtzset(3), time(2), tzfile(5)