Penguin
Annotated edit history of strftime(3) version 2, including all changes. View license author blame.
Rev Author # Line
1 perry 1 STRFTIME
2 !!!STRFTIME
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 RETURN VALUE
7 ENVIRONMENT
8 CONFORMING TO
9 SEE ALSO
10 ----
11 !!NAME
12
13
14 strftime - format date and time
15 !!SYNOPSIS
16
17
18 __#include
19 __''s''__, size_t__ ''max''__, const char *__''format''__,
20 const struct tm *__''tm''__);
21 __
22 !!DESCRIPTION
23
24
25 The __strftime()__ function formats the broken-down time
26 ''tm'' according to the format specification
27 ''format'' and places the result in the character array
28 ''s'' of size ''max''.
29
30
31 Ordinary characters placed in the format string are copied
32 to ''s'' without conversion. Conversion specifiers are
33 introduced by a `%' character, and are replaced in ''s''
34 as follows:
35
36
37 __%a__
38
39
40 The abbreviated weekday name according to the current
41 locale.
42
43
44 __%A__
45
46
47 The full weekday name according to the current
48 locale.
49
50
51 __%b__
52
53
54 The abbreviated month name according to the current
55 locale.
56
57
58 __%B__
59
60
61 The full month name according to the current
62 locale.
63
64
65 __%c__
66
67
68 The preferred date and time representation for the current
69 locale.
70
71
72 __%C__
73
74
75 The century number (year/100) as a 2-digit integer.
76 (SU)
77
78
79 __%C__
80
81
82 The century number (the year divided by 100 and truncated to
83 an integer).
84
85
86 __%d__
87
88
89 The day of the month as a decimal number (range 01 to
90 31).
91
92
93 __%D__
94
95
96 Equivalent to %m/%d/%y. (Yecch - for Americans only.
97 Americans should note that in other countries %d/%m/%y is
98 rather common. This means that in international context this
99 format is ambiguous and should not be used.)
100 (SU)
101
102
103 __%e__
104
105
106 Like %d, the day of the month as a decimal number, but a
107 leading zero is replaced by a space. (SU)
108
109
110 __%E__
111
112
113 Modifier: use alternative format, see below.
114 (SU)
115
116
117 __%G__
118
119
120 The ISO 8601 year with century as a decimal number. The
121 4-digit year corresponding to the ISO week number (see %V).
122 This has the same format and value as %y, except that if the
123 ISO week number belongs to the previous or next year, that
124 year is used instead. (TZ)
125
126
127 __%g__
128
129
130 Like %G, but without century, i.e., with a 2-digit year
131 (00-99). (TZ)
132
133
134 __%h__
135
136
137 Equivalent to %b. (SU)
138
139
140 __%H__
141
142
143 The hour as a decimal number using a 24-hour clock (range 00
144 to 23).
145
146
147 __%I__
148
149
150 The hour as a decimal number using a 12-hour clock (range 01
151 to 12).
152
153
154 __%j__
155
156
157 The day of the year as a decimal number (range 001 to
158 366).
159
160
161 __%k__
162
163
164 The hour (24-hour clock) as a decimal number (range 0 to
165 23); single digits are preceded by a blank. (See also %H.)
166 (TZ)
167
168
169 __%l__
170
171
172 The hour (12-hour clock) as a decimal number (range 1 to
173 12); single digits are preceded by a blank. (See also %I.)
174 (TZ)
175
176
177 __%m__
178
179
180 The month as a decimal number (range 01 to 12).
181
182
183 __%M__
184
185
186 The minute as a decimal number (range 00 to
187 59).
188
189
190 __%n__
191
192
193 A newline character. (SU)
194
195
196 __%O__
197
198
199 Modifier: use alternative format, see below.
200 (SU)
201
202
203 __%p__
204
205
206 Either `AM' or `PM' according to the given time value, or
207 the corresponding strings for the current locale. Noon is
208 treated as `pm' and midnight as `am'.
209
210
211 __%P__
212
213
214 Like %p but in lowercase: `am' or `pm' or a corresponding
215 string for the current locale. (GNU)
216
217
218 __%r__
219
220
221 The time in a.m. or p.m. notation. In the POSIX locale this
222 is equivalent to `%I:%M:%S %p'. (SU)
223
224
225 __%R__
226
227
228 The time in 24-hour notation (%H:%M). (SU) For a version
229 including the seconds, see %T below.
230
231
232 __%s__
233
234
235 The number of seconds since the Epoch, i.e., since
236 1970-01-01 00:00:00 UTC. (TZ)
237
238
239 __%S__
240
241
242 The second as a decimal number (range 00 to
243 61).
244
245
246 __%t__
247
248
249 A tab character. (SU)
250
251
252 __%T__
253
254
255 The time in 24-hour notation (%H:%M:%S). (SU)
256
257
258 __%u__
259
260
261 The day of the week as a decimal, range 1 to 7, Monday being
262 1. See also %w. (SU)
263
264
265 __%U__
266
267
268 The week number of the current year as a decimal number,
269 range 00 to 53, starting with the first Sunday as the first
270 day of week 01. See also %V and %W.
271
272
273 __%V__
274
275
276 The ISO 8601:1988 week number of the current year as a
277 decimal number, range 01 to 53, where week 1 is the first
278 week that has at least 4 days in the current year, and with
279 Monday as the first day of the week. See also %U and %W.
280 (SU)
281
282
283 __%w__
284
285
286 The day of the week as a decimal, range 0 to 6, Sunday being
287 0. See also %u.
288
289
290 __%W__
291
292
293 The week number of the current year as a decimal number,
294 range 00 to 53, starting with the first Monday as the first
295 day of week 01.
296
297
298 __%x__
299
300
301 The preferred date representation for the current locale
302 without the time.
303
304
305 __%X__
306
307
308 The preferred time representation for the current locale
309 without the date.
310
311
312 __%y__
313
314
315 The year as a decimal number without a century (range 00 to
316 99).
317
318
319 __%Y__
320
321
322 The year as a decimal number including the
323 century.
324
325
326 __%z__
327
328
329 The time-zone as hour offset from GMT. Required to emit
330 RFC822-conformant dates (using
331
332
333 __%Z__
334
335
336 The time zone or name or abbreviation.
337
338
339 __%+__
340
341
342 The date and time in date(1) format. (TZ)
343
344
345 __%%__
346
347
348 A literal `%' character.
349
350
351 Some conversion specifiers can be modified by preceding them
352 by the E or O modifier to indicate that an alternative
353 format should be used. If the alternative format or
354 specification does not exist for the current locale, the
355 behaviour will be as if the unmodified conversion
356 specification were used. (SU) The Single Unix Specification
357 mentions %Ec, %EC, %Ex, %EX, %Ry, %EY, %Od, %Oe, %OH, %OI,
358 %Om, %OM, %OS, %Ou, %OU, %OV, %Ow, %OW, %Oy, where the
359 effect of the O modifier is to use alternative numeric
360 symbols (say, roman numerals), and that of the E modifier is
361 to use a locale-dependent alternative
362 representation.
363
364
365 The broken-down time structure ''tm'' is defined in
366 ''''. See also
367 ctime(3).
368 !!RETURN VALUE
369
370
371 The __strftime()__ function returns the number of
372 characters placed in the array ''s'', not including the
373 terminating NUL character, provided the string, including
374 the terminating NUL, fits. Otherwise, it returns 0, and the
375 contents of the array is undefined. (Thus at least since
376 libc 4.4.4; very old versions of libc, such as libc 4.4.1,
377 would return ''max'' if the array was too
378 small.)
379
380
381 Note that the return value 0 does not necessarily indicate
382 an error; for example, in many locales %p yields an empty
383 string.
384 !!ENVIRONMENT
385
386
387 The environment variables TZ and LC_TIME are
388 used.
389 !!CONFORMING TO
390
391
392 ANSI C, SVID 3, ISO 9899. There are strict inclusions
393 between the set of conversions given in ANSI C (unmarked),
394 those given in the Single Unix Specification (marked SU),
395 those given in Olson's timezone package (marked TZ), and
396 those given in glibc (marked GNU), except that %+ is not
397 supported in glibc2. On the other hand glibc2 has several
398 more extensions. POSIX.1 only refers to ANSI C; POSIX.2
399 describes under date(1) several extensions that could
400 apply to __strftime__ as well.
401 !!SEE ALSO
402
403
2 IanMcDonald 404 [date(1)], [time(2)], [ctime(3)],
405 [setlocale(3)], [sprintf(3)]
1 perry 406 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.