1STRFTIME(3P)               POSIX Programmer's Manual              STRFTIME(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       strftime, strftime_l — convert date and time to a string
13

SYNOPSIS

15       #include <time.h>
16
17       size_t strftime(char *restrict s, size_t maxsize,
18           const char *restrict format, const struct tm *restrict timeptr);
19       size_t strftime_l(char *restrict s, size_t maxsize,
20           const char *restrict format, const struct tm *restrict timeptr,
21           locale_t locale);
22

DESCRIPTION

24       For strftime(): The functionality described on this reference  page  is
25       aligned  with the ISO C standard. Any conflict between the requirements
26       described here and the ISO C standard is unintentional. This volume  of
27       POSIX.1‐2017 defers to the ISO C standard.
28
29       The  strftime() function shall place bytes into the array pointed to by
30       s as controlled by the string pointed to by format.  The  format  is  a
31       character  string,  beginning and ending in its initial shift state, if
32       any. The format string consists of zero or more  conversion  specifica‐
33       tions and ordinary characters.
34
35       Each  conversion specification is introduced by the '%' character after
36       which the following appear in sequence:
37
38        *  An optional flag:
39
40           0     The zero character ('0'), which specifies that the  character
41                 used as the padding character is '0',
42
43           +     The  <plus-sign>  character  ('+'),  which specifies that the
44                 character used as the padding character is '0', and  that  if
45                 and  only if the field being produced consumes more than four
46                 bytes to represent a year (for %F, %G, or %Y)  or  more  than
47                 two  bytes to represent the year divided by 100 (for %C) then
48                 a leading <plus-sign> character shall be included if the year
49                 being processed is greater than or equal to zero or a leading
50                 <hyphen-minus> character ('-') shall be included if the  year
51                 is less than zero.
52
53           The default padding character is unspecified.
54
55        *  An  optional minimum field width. If the converted value, including
56           any leading '+' or '-' sign, has fewer bytes than the minimum field
57           width  and the padding character is not the NUL character, the out‐
58           put shall be padded on the left (after any leading '+' or '-' sign)
59           with the padding character.
60
61        *  An optional E or O modifier.
62
63        *  A  terminating  conversion  specifier  character that indicates the
64           type of conversion to be applied.
65
66       The results are unspecified if more than one flag character  is  speci‐
67       fied,  a  flag  character is specified without a minimum field width; a
68       minimum field width is specified without a flag character;  a  modifier
69       is specified with a flag or with a minimum field width; or if a minimum
70       field width is specified for any conversion specifier other than C,  F,
71       G, or Y.
72
73       All  ordinary  characters (including the terminating NUL character) are
74       copied unchanged into the array. If copying takes place between objects
75       that overlap, the behavior is undefined. No more than maxsize bytes are
76       placed into the array. Each conversion specifier is replaced by  appro‐
77       priate  characters  as described in the following list. The appropriate
78       characters are determined using the LC_TIME  category  of  the  current
79       locale  and  by  the  values of zero or more members of the broken-down
80       time structure pointed to by timeptr, as specified in brackets  in  the
81       description.  If  any  of  the  specified values are outside the normal
82       range, the characters stored are unspecified.
83
84       The strftime_l() function shall be equivalent to the  strftime()  func‐
85       tion,  except  that the locale data used is from the locale represented
86       by locale.
87
88       Local timezone information is used as though strftime() called tzset().
89
90       The following conversion specifiers shall be supported:
91
92       a       Replaced by the locale's abbreviated weekday name. [tm_wday]
93
94       A       Replaced by the locale's full weekday name. [tm_wday]
95
96       b       Replaced by the locale's abbreviated month name. [tm_mon]
97
98       B       Replaced by the locale's full month name. [tm_mon]
99
100       c       Replaced by the locale's appropriate date and time  representa‐
101               tion.   (See  the  Base  Definitions  volume  of  POSIX.1‐2017,
102               <time.h>.)
103
104       C       Replaced by the year divided by 100 and truncated to  an  inte‐
105               ger, as a decimal number. [tm_year]
106
107               If  a minimum field width is not specified, the number of char‐
108               acters placed into the array pointed to by s will be the number
109               of  digits  in  the  year  divided  by 100 or two, whichever is
110               greater.  If a minimum field width is specified, the number  of
111               characters  placed  into  the array pointed to by s will be the
112               number of digits in the year divided  by  100  or  the  minimum
113               field width, whichever is greater.
114
115       d       Replaced  by  the day of the month as a decimal number [01,31].
116               [tm_mday]
117
118       D       Equivalent to %m/%d/%y.  [tm_mon, tm_mday, tm_year]
119
120       e       Replaced by the day of the month as a decimal number [1,31];  a
121               single digit is preceded by a space. [tm_mday]
122
123       F       Equivalent  to %+4Y-%m-%d if no flag and no minimum field width
124               are specified. [tm_year, tm_mon, tm_mday]
125
126               If a minimum field width of x is specified, the year  shall  be
127               output as if by the Y specifier (described below) with whatever
128               flag was given and a minimum field width of x-6.  If x is  less
129               than 6, the behavior shall be as if x equalled 6.
130
131               If  the minimum field width is specified to be 10, and the year
132               is four digits long, then the output string produced will match
133               the ISO 8601:2004 standard subclause 4.1.2.2 complete represen‐
134               tation, extended format date representation of a specific  day.
135               If  a + flag is specified, a minimum field width of x is speci‐
136               fied, and x-7 bytes are sufficient to hold the  digits  of  the
137               year (not including any needed sign character), then the output
138               will match the ISO 8601:2004 standard  subclause  4.1.2.4  com‐
139               plete  representation, expanded format date representation of a
140               specific day.
141
142       g       Replaced by the last 2  digits  of  the  week-based  year  (see
143               below) as a decimal number [00,99]. [tm_year, tm_wday, tm_yday]
144
145       G       Replaced by the week-based year (see below) as a decimal number
146               (for example, 1977). [tm_year, tm_wday, tm_yday]
147
148               If a minimum field width is specified, the number of characters
149               placed  into  the  array  pointed to by s will be the number of
150               digits and leading sign characters (if any) in the year, or the
151               minimum field width, whichever is greater.
152
153       h       Equivalent to %b.  [tm_mon]
154
155       H       Replaced  by  the  hour  (24-hour  clock)  as  a decimal number
156               [00,23]. [tm_hour]
157
158       I       Replaced by the  hour  (12-hour  clock)  as  a  decimal  number
159               [01,12]. [tm_hour]
160
161       j       Replaced  by the day of the year as a decimal number [001,366].
162               [tm_yday]
163
164       m       Replaced by the month as a decimal number [01,12]. [tm_mon]
165
166       M       Replaced by the minute as a decimal number [00,59]. [tm_min]
167
168       n       Replaced by a <newline>.
169
170       p       Replaced by the locale's equivalent  of  either  a.m.  or  p.m.
171               [tm_hour]
172
173       r       Replaced  by  the  time in a.m. and p.m. notation; in the POSIX
174               locale this shall be  equivalent  to  %I:%M:%S  %p.   [tm_hour,
175               tm_min, tm_sec]
176
177       R       Replaced  by  the  time in 24-hour notation (%H:%M).  [tm_hour,
178               tm_min]
179
180       S       Replaced by the second as a decimal number [00,60]. [tm_sec]
181
182       t       Replaced by a <tab>.
183
184       T       Replaced by the time (%H:%M:%S).  [tm_hour, tm_min, tm_sec]
185
186       u       Replaced by the weekday as a decimal number [1,7], with 1  rep‐
187               resenting Monday. [tm_wday]
188
189       U       Replaced  by  the  week  number of the year as a decimal number
190               [00,53].  The first Sunday of January is the first day of  week
191               1;  days  in  the new year before this are in week 0. [tm_year,
192               tm_wday, tm_yday]
193
194       V       Replaced by the week number of the year (Monday  as  the  first
195               day  of the week) as a decimal number [01,53]. If the week con‐
196               taining 1 January has four or more days in the new  year,  then
197               it is considered week 1.  Otherwise, it is the last week of the
198               previous year, and the next week is week 1.  Both  January  4th
199               and  the  first  Thursday  of  January  are  always  in week 1.
200               [tm_year, tm_wday, tm_yday]
201
202       w       Replaced by the weekday as a decimal number [0,6], with 0  rep‐
203               resenting Sunday. [tm_wday]
204
205       W       Replaced  by  the  week  number of the year as a decimal number
206               [00,53].  The first Monday of January is the first day of  week
207               1;  days  in  the new year before this are in week 0. [tm_year,
208               tm_wday, tm_yday]
209
210       x       Replaced by the locale's appropriate date representation.  (See
211               the Base Definitions volume of POSIX.1‐2017, <time.h>.)
212
213       X       Replaced  by the locale's appropriate time representation. (See
214               the Base Definitions volume of POSIX.1‐2017, <time.h>.)
215
216       y       Replaced by the last two digits of the year as a decimal number
217               [00,99]. [tm_year]
218
219       Y       Replaced  by  the year as a decimal number (for example, 1997).
220               [tm_year]
221
222               If a minimum field width is specified, the number of characters
223               placed  into  the  array  pointed to by s will be the number of
224               digits and leading sign characters (if any) in the year, or the
225               minimum field width, whichever is greater.
226
227       z       Replaced  by  the offset from UTC in the ISO 8601:2004 standard
228               format (+hhmm or -hhmm), or by no characters if no timezone  is
229               determinable.  For  example,  "-0430"  means 4 hours 30 minutes
230               behind UTC (west of Greenwich).  If tm_isdst is zero, the stan‐
231               dard time offset is used. If tm_isdst is greater than zero, the
232               daylight savings time offset is used. If tm_isdst is  negative,
233               no characters are returned.  [tm_isdst]
234
235       Z       Replaced  by  the timezone name or abbreviation, or by no bytes
236               if no timezone information exists. [tm_isdst]
237
238       %       Replaced by %.
239
240       If a conversion specification does not correspond to any of the  above,
241       the behavior is undefined.
242
243       If  a struct tm broken-down time structure is created by localtime() or
244       localtime_r(), or modified by mktime(), and the value of TZ  is  subse‐
245       quently  modified,  the  results of the %Z and %z strftime() conversion
246       specifiers are undefined, when strftime() is called with such a broken-
247       down time structure.
248
249       If  a  struct  tm  broken-down time structure is created or modified by
250       gmtime() or gmtime_r(), it is unspecified whether the result of the  %Z
251       and  %z  conversion  specifiers shall refer to UTC or the current local
252       timezone, when strftime() is called with such a broken-down time struc‐
253       ture.
254
255   Modified Conversion Specifiers
256       Some conversion specifiers can be modified by the E or O modifier char‐
257       acters to indicate that an alternative format or  specification  should
258       be  used rather than the one normally used by the unmodified conversion
259       specifier. If the alternative format or specification  does  not  exist
260       for  the  current  locale  (see  ERA  in the Base Definitions volume of
261       POSIX.1‐2017, Section 7.3.5, LC_TIME), the behavior shall be as if  the
262       unmodified conversion specification were used.
263
264       %Ec     Replaced  by the locale's alternative appropriate date and time
265               representation.
266
267       %EC     Replaced by the name of the base year (period) in the  locale's
268               alternative representation.
269
270       %Ex     Replaced by the locale's alternative date representation.
271
272       %EX     Replaced by the locale's alternative time representation.
273
274       %Ey     Replaced  by  the  offset  from %EC (year only) in the locale's
275               alternative representation.
276
277       %EY     Replaced by the full alternative year representation.
278
279       %Od     Replaced by the day of the month, using the  locale's  alterna‐
280               tive  numeric  symbols,  filled as needed with leading zeros if
281               there is any alternative symbol for zero; otherwise, with lead‐
282               ing <space> characters.
283
284       %Oe     Replaced  by  the day of the month, using the locale's alterna‐
285               tive numeric symbols, filled as  needed  with  leading  <space>
286               characters.
287
288       %OH     Replaced  by the hour (24-hour clock) using the locale's alter‐
289               native numeric symbols.
290
291       %OI     Replaced by the hour (12-hour clock) using the locale's  alter‐
292               native numeric symbols.
293
294       %Om     Replaced  by  the  month using the locale's alternative numeric
295               symbols.
296
297       %OM     Replaced by the minutes using the locale's alternative  numeric
298               symbols.
299
300       %OS     Replaced  by the seconds using the locale's alternative numeric
301               symbols.
302
303       %Ou     Replaced by the weekday as a number in the locale's alternative
304               representation (Monday=1).
305
306       %OU     Replaced  by  the  week number of the year (Sunday as the first
307               day of the week, rules corresponding to %U) using the  locale's
308               alternative numeric symbols.
309
310       %OV     Replaced  by  the  week number of the year (Monday as the first
311               day of the week, rules corresponding to %V) using the  locale's
312               alternative numeric symbols.
313
314       %Ow     Replaced  by  the  number  of  the weekday (Sunday=0) using the
315               locale's alternative numeric symbols.
316
317       %OW     Replaced by the week number of the year (Monday  as  the  first
318               day  of  the  week) using the locale's alternative numeric sym‐
319               bols.
320
321       %Oy     Replaced by the year (offset from %C) using the locale's alter‐
322               native numeric symbols.
323
324       %g,  %G,  and  %V  give  values according to the ISO 8601:2004 standard
325       week-based year. In this system, weeks begin on a Monday and week 1  of
326       the  year is the week that includes January 4th, which is also the week
327       that includes the first Thursday of the year, and  is  also  the  first
328       week  that contains at least four days in the year. If the first Monday
329       of January is the 2nd, 3rd, or 4th, the preceding days are part of  the
330       last  week  of the preceding year; thus, for Saturday 2nd January 1999,
331       %G is replaced by 1998 and %V is replaced  by  53.  If  December  29th,
332       30th, or 31st is a Monday, it and any following days are part of week 1
333       of the following year. Thus, for Tuesday  30th  December  1997,  %G  is
334       replaced by 1998 and %V is replaced by 01.
335
336       If  a  conversion  specifier  is  not one of the above, the behavior is
337       undefined.
338
339       The behavior is undefined if the locale argument to strftime_l() is the
340       special  locale object LC_GLOBAL_LOCALE or is not a valid locale object
341       handle.
342

RETURN VALUE

344       If the total number of resulting bytes including the  terminating  null
345       byte  is not more than maxsize, these functions shall return the number
346       of bytes placed into the array pointed to by s, not including the  ter‐
347       minating NUL character. Otherwise, 0 shall be returned and the contents
348       of the array are unspecified.
349

ERRORS

351       No errors are defined.
352
353       The following sections are informative.
354

EXAMPLES

356   Getting a Localized Date String
357       The following example first sets the locale to the user's default.  The
358       locale  information  will  be  used in the nl_langinfo() and strftime()
359       functions. The nl_langinfo() function returns the localized date string
360       which specifies how the date is laid out. The strftime() function takes
361       this information and, using the tm structure  for  values,  places  the
362       date and time information into datestring.
363
364
365           #include <time.h>
366           #include <locale.h>
367           #include <langinfo.h>
368           ...
369           struct tm *tm;
370           char datestring[256];
371           ...
372           setlocale (LC_ALL, "");
373           ...
374           strftime (datestring, sizeof(datestring), nl_langinfo (D_T_FMT), tm);
375           ...
376

APPLICATION USAGE

378       The  range of values for %S is [00,60] rather than [00,59] to allow for
379       the occasional leap second.
380
381       Some of the conversion specifications are duplicates  of  others.  They
382       are  included  for  compatibility  with  nl_cxtime() and nl_ascxtime(),
383       which were published in Issue 2.
384
385       The %C, %F, %G, and %Y format specifiers  in  strftime()  always  print
386       full  values,  but the strptime() %C, %F, and %Y format specifiers only
387       scan two digits (assumed to be the first two  digits  of  a  four-digit
388       year)  for  %C  and  four digits (assumed to be the entire (four-digit)
389       year) for %F and %Y.  This mimics the behavior of printf() and scanf();
390       that is:
391
392
393           printf("%2d", x = 1000);
394
395       prints "1000", but:
396
397
398           scanf(%2d", &x);
399
400       when  given  "1000"  as  input  will only store 10 in x).  Applications
401       using extended ranges of years must be sure that the number  of  digits
402       specified for scanning years with strptime() matches the number of dig‐
403       its that will actually be present in the input stream. Historic  imple‐
404       mentations  of  the  %Y  conversion specification (with no flags and no
405       minimum field width) produced different  output  formats.  Some  always
406       produced  at  least  four  digits (with 0 fill for years from 0 through
407       999) while others only produced the number of  digits  present  in  the
408       year  (with  no  fill  and no padding). These two forms can be produced
409       with the '0' flag and a minimum field width options using  the  conver‐
410       sions specifications %04Y and %01Y, respectively.
411
412       In  the  past,  the C and POSIX standards specified that %F produced an
413       ISO 8601:2004 standard date format, but didn't specify which  one.  For
414       years  in  the range [0001,9999], POSIX.1‐2008 requires that the output
415       produced  match  the  ISO 8601:2004  standard  complete  representation
416       extended  format  (YYYY-MM-DD) and for years outside of this range pro‐
417       duce output that matches the ISO 8601:2004 standard expanded  represen‐
418       tation  extended  format  (<+/-><Underline>Y</Underline>YYYY-MM-DD). To
419       fully meet ISO 8601:2004 standard requirements, the producer  and  con‐
420       sumer  must  agree on a date format that has a specific number of bytes
421       reserved to hold the characters used to represent  the  years  that  is
422       sufficiently large to hold all values that will be shared. For example,
423       the %+13F conversion specification will  produce  output  matching  the
424       format  "<+/->YYYYYY-MM-DD"  (a  leading  '+' or '-' sign; a six-digit,
425       0-filled year; a '-'; a two-digit, leading 0-filled month; another '-';
426       and the two-digit, leading 0-filled day within the month).
427
428       Note that if the year being printed is greater than 9999, the resulting
429       string from the unadorned %F conversion specifications will not conform
430       to  the ISO 8601:2004 standard extended format, complete representation
431       for a date and will instead be an extended format, expanded representa‐
432       tion (presumably without the required agreement between the date's pro‐
433       ducer and consumer).
434
435       In the C or POSIX locale, the E and O modifiers  are  ignored  and  the
436       replacement strings for the following specifiers are:
437
438       %a      The first three characters of %A.
439
440       %A      One of Sunday, Monday, ..., Saturday.
441
442       %b      The first three characters of %B.
443
444       %B      One of January, February, ..., December.
445
446       %c      Equivalent to %a %b %e %T %Y.
447
448       %p      One of AM or PM.
449
450       %r      Equivalent to %I:%M:%S %p.
451
452       %x      Equivalent to %m/%d/%y.
453
454       %X      Equivalent to %T.
455
456       %Z      Implementation-defined.
457

RATIONALE

459       The %Y conversion specification to strftime() was frequently assumed to
460       be a four-digit year, but the ISO C standard does not specify  that  %Y
461       is  restricted  to any subset of allowed values from the tm_year field.
462       Similarly, the %C conversion specification was assumed  to  be  a  two-
463       digit  field  and  the  first part of the output from the %F conversion
464       specification was assumed to be a four-digit field. With tm_year  being
465       a  signed 32 or more-bit int and with many current implementations sup‐
466       porting 64-bit time_t types in one or  more  programming  environments,
467       these assumptions are clearly wrong.
468
469       POSIX.1‐2008 now allows the format specifications %0xC, %0xF, %0xG, and
470       %0xY (where 'x' is a string of decimal digits used to specify  printing
471       and  scanning  of  a string of x decimal digits) with leading zero fill
472       characters. Allowing applications to set the field width  enables  them
473       to  agree  on  the  number  of  digits to be printed and scanned in the
474       ISO 8601:2004 standard expanded representation of a year (for  %F,  %G,
475       and  %Y)  or all but the last two digits of the year (for %C).  This is
476       based on a feature in some versions of GNU libc's strftime().  The  GNU
477       version  allows  specifying space, zero, or no-fill characters in strf‐
478       time() format strings, but does not allow any flags to be specified  in
479       strptime() format strings. These implementations also allow these flags
480       to be specified for any numeric field. POSIX.1‐2008 only  requires  the
481       zero  fill flag ('0') and only requires that it be recognized when pro‐
482       cessing %C, %F, %G, and %Y specifications when a minimum field width is
483       also  specified.  The  '0'  flag is the only flag needed to produce and
484       scan the ISO 8601:2004 standard year fields using the  extended  format
485       forms.  POSIX.1‐2008  also allows applications to specify the same flag
486       and field width specifiers to be used in both strftime() and strptime()
487       format  strings for symmetry. Systems may provide other flag characters
488       and may accept flags in conjunction with  conversion  specifiers  other
489       than  %C,  %F,  %G,  and %Y; but portable applications cannot depend on
490       such extensions.
491
492       POSIX.1‐2008 now also allows  the  format  specifications  %+xC,  %+xF,
493       %+xG, and %+xY (where 'x' is a string of decimal digits used to specify
494       printing and scanning of a string of 'x' decimal digits)  with  leading
495       zero fill characters and a leading '+' sign character if the year being
496       converted is more than four digits or a minimum field width  is  speci‐
497       fied  that  allows  room  for  more than four digits for the year. This
498       allows date providers and consumers to agree on a  specific  number  of
499       digits  to  represent  a year as required by the ISO 8601:2004 standard
500       expanded representation formats. The  expanded  representation  formats
501       all  require the year to begin with a leading '+' or '-' sign.  (All of
502       these specifiers can also provide  a  leading  '-'  sign  for  negative
503       years. Since negative years and the year 0 don't fit well with the Gre‐
504       gorian or Julian calendars, the normal ranges of dates start with  year
505       1.  The ISO C standard allows tm_year to assume values corresponding to
506       years before year 1, but the use of  such  years  provided  unspecified
507       results.)
508
509       Some earlier version of this standard specified that applications want‐
510       ing to use strptime() to scan dates and  times  printed  by  strftime()
511       should  provide  non-digit  characters between fields to separate years
512       from months and days. It also  supported  %F  to  print  and  scan  the
513       ISO 8601:2004  standard  extended  format, complete representation date
514       for years 1 through 9999 (i.e., YYYY-MM-DD). However, many applications
515       were  written  to  print (using strftime()) and scan (using strptime())
516       dates written using the basic  format  complete  representation  (four-
517       digit  years)  and truncated representation (two-digit years) specified
518       by the ISO 8601:2004 standard representation of dates and  times  which
519       do not have any separation characters between fields. The ISO 8601:2004
520       standard also specifies basic format expanded representation where  the
521       creator  and  consumer  of  these  fields agree beforehand to represent
522       years as leading zero-filled strings of an agreed length of  more  than
523       four  digits  to  represent a year (again with no separation characters
524       when year, month, and day are all  displayed).  Applications  producing
525       and  consuming  expanded  representations are encouraged to use the '+'
526       flag and an appropriate maximum field width to scan the year  including
527       the  leading sign. Note that even without the '+' flag, years less than
528       zero may be represented with a leading <hyphen-minus> for %F,  %G,  and
529       %Y  conversion specifications. Using negative years results in unspeci‐
530       fied behavior.
531
532       If a format specification %+xF with the field width x greater  than  11
533       is  specified  and  the width is large enough to display the full year,
534       the output string produced will match the ISO 8601:2004  standard  sub‐
535       clause  4.1.2.4 expanded representation, extended format date represen‐
536       tation for a specific day. (For years in the range [1,99999], %+12F  is
537       sufficient  for an agreed five-digit year with a leading sign using the
538       ISO 8601:2004 standard expanded representation, extended format  for  a
539       specific day "<+/->YYYYY-MM-DD".)  Note also that years less than 0 may
540       produce a leading <hyphen-minus> character ('-') when using  %Y  or  %C
541       whether or not the '0' or '+' flags are used.
542
543       The  difference  between  the  '0' flag and the '+' flag is whether the
544       leading '+' character will be provided for years >9999 as required  for
545       the  ISO 8601:2004 standard extended representation format containing a
546       year. For example:
547
548           ┌───────┬──────────────────────────┬─────────────┬────────────┐
549           │       │                          │ strftime()  strptime() 
550Year  Conversion Specification Output    Scan Back  
551           ├───────┼──────────────────────────┼─────────────┼────────────┤
552           │1970   │ %Y                       │ 1970        │ 1970       │
553           ├───────┼──────────────────────────┼─────────────┼────────────┤
554           │1970   │ %+4Y                     │ 1970        │ 1970       │
555           ├───────┼──────────────────────────┼─────────────┼────────────┤
556           │27     │ %Y                       │ 27 or 0027  │ 27         │
557           ├───────┼──────────────────────────┼─────────────┼────────────┤
558           │270    │ %Y                       │ 270 or 0270 │ 270        │
559           ├───────┼──────────────────────────┼─────────────┼────────────┤
560           │270    │ %+4Y                     │ 0270        │ 270        │
561           ├───────┼──────────────────────────┼─────────────┼────────────┤
562           │17     │ %C%y                     │ 0017        │ 17         │
563           ├───────┼──────────────────────────┼─────────────┼────────────┤
564           │270    │ %C%y                     │ 0270        │ 270        │
565           ├───────┼──────────────────────────┼─────────────┼────────────┤
566           │12345  │ %Y                       │ 12345       │ 1234*      │
567           ├───────┼──────────────────────────┼─────────────┼────────────┤
568           │12345  │ %+4Y                     │ +12345      │ 123*       │
569           ├───────┼──────────────────────────┼─────────────┼────────────┤
570           │12345  │ %05Y                     │ 12345       │ 12345      │
571           ├───────┼──────────────────────────┼─────────────┼────────────┤
572           │270    │ %+5Y or %+3C%y           │ +0270       │ 270        │
573           ├───────┼──────────────────────────┼─────────────┼────────────┤
574           │12345  │ %+5Y or %+3C%y           │ +12345      │ 1234*      │
575           ├───────┼──────────────────────────┼─────────────┼────────────┤
576           │12345  │ %06Y or %04C%y           │ 012345      │ 12345      │
577           ├───────┼──────────────────────────┼─────────────┼────────────┤
578           │12345  │ %+6Y or %+4C%y           │ +12345      │ 12345      │
579           ├───────┼──────────────────────────┼─────────────┼────────────┤
580           │123456 │ %08Y or %06C%y           │ 00123456    │ 123456     │
581           ├───────┼──────────────────────────┼─────────────┼────────────┤
582           │123456 │ %+8Y or %+6C%y           │ +0123456    │ 123456     │
583           └───────┴──────────────────────────┴─────────────┴────────────┘
584       In the cases above marked with a * in the strptime() scan  back  field,
585       the implied or specified number of characters scanned by strptime() was
586       less than the number of characters output by strftime() using the  same
587       format;  so the remaining digits of the year were dropped when the out‐
588       put date produced by strftime() was scanned back in by strptime().
589

FUTURE DIRECTIONS

591       None.
592

SEE ALSO

594       asctime(), clock(), ctime(), difftime(),  getdate(),  gmtime(),  local‐
595       time(), mktime(), strptime(), time(), tzset(), uselocale(), utime()
596
597       The  Base  Definitions  volume of POSIX.1‐2017, Section 7.3.5, LC_TIME,
598       <time.h>
599
601       Portions of this text are reprinted and reproduced in  electronic  form
602       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
603       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
604       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
605       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
606       event of any discrepancy between this version and the original IEEE and
607       The Open Group Standard, the original IEEE and The Open Group  Standard
608       is  the  referee document. The original Standard can be obtained online
609       at http://www.opengroup.org/unix/online.html .
610
611       Any typographical or formatting errors that appear  in  this  page  are
612       most likely to have been introduced during the conversion of the source
613       files to man page format. To report such errors,  see  https://www.ker
614       nel.org/doc/man-pages/reporting_bugs.html .
615
616
617
618IEEE/The Open Group                  2017                         STRFTIME(3P)
Impressum