1 NEWSTRFTIME(3) Library Functions Manual NEWSTRFTIME(3)
4 strftime - format date and time
9 size_t strftime(char *restrict buf, size_t maxsize,
10 char const *restrict format, struct tm const *restrict timeptr);
15 The strftime function formats the information from timeptr into the
16 buffer buf according to the string pointed to by format.
18 The format string consists of zero or more conversion specifications
19 and ordinary characters. All ordinary characters are copied directly
20 into the buffer. A conversion specification consists of a percent sign
21 and one other character.
23 No more than maxsize characters are placed into the array. If the
24 total number of resulting characters, including the terminating null
25 character, is not more than maxsize, strftime returns the number of
26 characters in the array, not counting the terminating null. Otherwise,
29 Each conversion specification is replaced by the characters as follows
30 which are then copied into the buffer.
32 %A is replaced by the locale's full weekday name.
34 %a is replaced by the locale's abbreviated weekday name.
36 %B is replaced by the locale's full month name.
39 is replaced by the locale's abbreviated month name.
41 %C is replaced by the century (a year divided by 100 and truncated
42 to an integer) as a decimal number (00-99).
44 %c is replaced by the locale's appropriate date and time
47 %D is replaced by the date in the format %m/%d/%y.
49 %d is replaced by the day of the month as a decimal number (01-31).
51 %e is replaced by the day of month as a decimal number (1-31);
52 single digits are preceded by a blank.
54 %F is replaced by the date in the format %Y-%m-%d.
56 %G is replaced by the ISO 8601 year with century as a decimal
59 %g is replaced by the ISO 8601 year without century as a decimal
62 %H is replaced by the hour (24-hour clock) as a decimal number
65 %I is replaced by the hour (12-hour clock) as a decimal number
68 %j is replaced by the day of the year as a decimal number
71 %k is replaced by the hour (24-hour clock) as a decimal number
72 (0-23); single digits are preceded by a blank.
74 %l is replaced by the hour (12-hour clock) as a decimal number
75 (1-12); single digits are preceded by a blank.
77 %M is replaced by the minute as a decimal number (00-59).
79 %m is replaced by the month as a decimal number (01-12).
81 %n is replaced by a newline.
83 %p is replaced by the locale's equivalent of either AM or PM.
85 %R is replaced by the time in the format %H:%M.
87 %r is replaced by the locale's representation of 12-hour clock time
90 %S is replaced by the second as a decimal number (00-60).
92 %s is replaced by the number of seconds since the Epoch (see
95 %T is replaced by the time in the format %H:%M:%S.
97 %t is replaced by a tab.
99 %U is replaced by the week number of the year (Sunday as the first
100 day of the week) as a decimal number (00-53).
102 %u is replaced by the weekday (Monday as the first day of the week)
103 as a decimal number (1-7).
105 %V is replaced by the week number of the year (Monday as the first
106 day of the week) as a decimal number (01-53). If the week
107 containing January 1 has four or more days in the new year, then
108 it is week 1; otherwise it is week 53 of the previous year, and
109 the next week is week 1.
111 %W is replaced by the week number of the year (Monday as the first
112 day of the week) as a decimal number (00-53).
114 %w is replaced by the weekday (Sunday as the first day of the week)
115 as a decimal number (0-6).
117 %X is replaced by the locale's appropriate time representation.
119 %x is replaced by the locale's appropriate date representation.
121 %Y is replaced by the year with century as a decimal number.
123 %y is replaced by the year without century as a decimal number
126 %Z is replaced by the time zone name, or by the empty string if
127 this is not determinable.
129 %z is replaced by the offset from the Prime Meridian in the format
130 +HHMM or -HHMM as appropriate, with positive values representing
131 locations east of Greenwich, or by the empty string if this is
132 not determinable. The numeric time zone -0000 is used when the
133 time is Universal Time but local time is indeterminate; by
134 convention this is used for locations while uninhabited, and
135 corresponds to a zero offset when the time zone abbreviation
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)