The strftime(), strftime_l(), ascftime(), and
cftime() functions place bytes into the array pointed to by s as
controlled by the string pointed to by format. The format string
consists of zero or more conversion specifications and ordinary characters. A
conversion specification consists of a '%' (percent) character and one
or two terminating conversion characters that determine the conversion
specification's behavior. All ordinary characters (including the terminating
null byte) are copied unchanged into the array pointed to by s. If
copying takes place between objects that overlap, the behavior is undefined.
For strftime(), no more than maxsize bytes are placed into the
array. The strftime_l() function behaves identically to
strftime() function, but instead of operating in the current locale, it
operates in the locale specified by loc.
If format is NULL, then the locale's default format
is used. For strftime() the default format is the same as %c;
for cftime() and ascftime() the default format is the same as
%+. cftime() and ascftime() first try to use the value
of the environment variable CFTIME, and if that is undefined or
empty, the default format is used.
Each conversion specification is replaced by appropriate
characters as described in the following list. The appropriate characters
are determined by the LC_TIME category of the program's locale and by
the values contained in the structure pointed to by timeptr for
strftime() and ascftime(), and by the time represented by
clock for cftime().
%%
Same as %.
%a
Locale's abbreviated weekday name.
%A
Locale's full weekday name.
%b
Locale's abbreviated month name.
%B
Locale's full month name.
%c
Locale's appropriate date and time representation. In the
C locale, this format is:
%a %b %e %H:%M:%S %Y
Other locales may have different locale-specific formats.
%C
Century number (the year divided by 100 and truncated to
an integer as a decimal number [01,99]).
%d
Day of month [01,31].
%D
Date as %m/%d/%y.
%e
Day of month [1,31]; single digits are preceded by a
space.
%F
Equivalent to %Y-%m-%d (the ISO
8601:2000 standard date format).
%g
Week-based year within century [00,99].
%G
Week-based year, including the century [0000,9999].
%h
Locale's abbreviated month name.
%H
Hour (24-hour clock) [00,23].
%I
Hour (12-hour clock) [01,12].
%j
Day number of year [001,366].
%k
Hour (24-hour clock) [0,23]; single digits are preceded
by a space.
%l
Hour (12-hour clock) [1,12]; single digits are preceded
by a space.
%m
Month number [01,12].
%M
Minute [00,59].
%n
Insert a NEWLINE.
%p
Locale's equivalent of either a.m. or p.m.
%r
Appropriate time representation in 12-hour clock format
with %p.
%R
Time as %H:%M.
%s
Seconds since 00:00:00 UTC, January 1, 1970.
%S
Seconds [00,60]; the range of values is [00,60] rather
than [00,59] to allow for the occasional leap second.
%t
Insert a TAB.
%T
Time as %H:%M:%S.
%u
Weekday as a decimal number [1,7], with 1 representing
Monday. See NOTES below.
%U
Week number of year as a decimal number [00,53], with
Sunday as the first day of week 1.
%v
Date as %e-%b-%Y.
%V
The ISO 8601 week number as a decimal number [01,53]. In
the ISO 8601 week-based system, weeks begin on a Monday and week 1 of the year
is the week that includes both January 4th and the first Thursday of the year.
If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are
part of the last week of the preceding year. See NOTES below.
%w
Weekday as a decimal number [0,6], with 0 representing
Sunday.
%W
Week number of year as a decimal number [00,53], with
Monday as the first day of week 1.
%x
Locale's appropriate date representation.
%X
Locale's appropriate time representation.
%y
Year within century [00,99].
%Y
Year, including the century (for example 1993).
%z
Replaced by offset from UTC in ISO 8601:2000 standard
format (+hhmm or -hhmm), or by no characters if no time zone is
determinable. For example, "-0430" means 4 hours 30 minutes behind
UTC (west of Greenwich). If tm_isdst is zero, the standard time offset
is used. If tm_isdst is greater than zero, the daylight savings time
offset if used. If tm_isdst is negative, no characters are
returned.
%Z
Time zone name or abbreviation, or no bytes if no time
zone information exists.
%+
Locale's date and time representation as produced by
date(1).
If a conversion specification does not correspond to any of the
above or to any of the modified conversion specifications listed below, the
behavior is undefined and 0 is returned.
The difference between %U and %W (and also between
modified conversion specifications %OU and %OW) lies in which
day is counted as the first of the week. Week number 1 is the first week in
January starting with a Sunday for %U or a Monday for %W. Week
number 0 contains those days before the first Sunday or Monday in January
for %U and %W, respectively.
Some conversion specifications can be modified by the E and O
modifiers to indicate that an alternate format or specification should be used
rather than the one normally used by the unmodified conversion specification.
If the alternate format or specification does not exist in the current locale,
the behavior will be as if the unmodified specification were used.
%Ec
Locale's alternate appropriate date and time
representation.
%EC
Name of the base year (period) in the locale's alternate
representation.
%Eg
Offset from %EC of the week-based year in the
locale's alternative representation.
%EG
Full alternative representation of the week-based
year.
%Ex
Locale's alternate date representation.
%EX
Locale's alternate time representation.
%Ey
Offset from %EC (year only) in the locale's
alternate representation.
%EY
Full alternate year representation.
%Od
Day of the month using the locale's alternate numeric
symbols.
%Oe
Same as %Od.
%Og
Week-based year (offset from %C) in the locale's
alternate representation and using the locale's alternate numeric
symbols.
%OH
Hour (24-hour clock) using the locale's alternate numeric
symbols.
%OI
Hour (12-hour clock) using the locale's alternate numeric
symbols.
%Om
Month using the locale's alternate numeric symbols.
%OM
Minutes using the locale's alternate numeric
symbols.
%OS
Seconds using the locale's alternate numeric
symbols.
%Ou
Weekday as a number in the locale's alternate numeric
symbols.
%OU
Week number of the year (Sunday as the first day of the
week) using the locale's alternate numeric symbols.
%Ow
Number of the weekday (Sunday=0) using the locale's
alternate numeric symbols.
%OW
Week number of the year (Monday as the first day of the
week) using the locale's alternate numeric symbols.
%Oy
Year (offset from %C) in the locale's alternate
representation and using the locale's alternate numeric symbols.
These routines produce output that is formatted according to the LC_TIME
locale category. They use either the current locale, or in the case of
strftime_l(), the locale supplied by loc.
Local time zone information is used as though tzset(3C) were called.