libc.info: strftime

Go forward to time
Go backward to mktime
Go up to Timefns
Go to the top op libc

`strftime'--flexible calendar time formatter

*Synopsis*
     #include <time.h>
     size_t strftime(char *S, size_t MAXSIZE,
         const char *FORMAT, const struct tm *TIMP);
   *Description*
`strftime' converts a `struct tm' representation of the time (at TIMP)
into a string, starting at S and occupying no more than MAXSIZE
characters.
   You control the format of the output using the string at FORMAT.
`*FORMAT' can contain two kinds of specifications: text to be copied
literally into the formatted string, and time conversion
specifications.  Time conversion specifications are two-character
sequences beginning with ``%'' (use ``%%'' to include a percent sign in
the output).  Each defined conversion specification selects a field of
calendar time data from `*TIMP', and converts it to a string in one of
the following ways:
`%a'
     An abbreviation for the day of the week.
`%A'
     The full name for the day of the week.
`%b'
     An abbreviation for the month name.
`%B'
     The full name of the month.
`%c'
     A string representing the complete date and time, in the form
           Mon Apr 01 13:13:13 1992
`%d'
     The day of the month, formatted with two digits.
`%e'
     The day of the month, formatted with leading space if single digit.
`%H'
     The hour (on a 24-hour clock), formatted with two digits.
`%I'
     The hour (on a 12-hour clock), formatted with two digits.
`%j'
     The count of days in the year, formatted with three digits (from
     ``001'' to ``366'').
`%m'
     The month number, formatted with two digits.
`%M'
     The minute, formatted with two digits.
`%p'
     Either ``AM'' or ``PM'' as appropriate.
`%S'
     The second, formatted with two digits.
`%U'
     The week number, formatted with two digits (from ``00'' to ``53'';
     week number 1 is taken as beginning with the first Sunday in a
     year).  See also `%W'.
`%w'
     A single digit representing the day of the week: Sunday is day `0'.
`%W'
     Another version of the week number: like ``%U'', but counting week
     1 as beginning with the first Monday in a year.
`o %x'
     A string representing the complete date, in a format like
           Mon Apr 01 1992
`%X'
     A string representing the full time of day (hours, minutes, and
     seconds), in a format like
           13:13:13
`%y'
     The last two digits of the year.
`%Y'
     The full year, formatted with four digits to include the century.
`%Z'
     The time zone name.  If tm_isdst is -1, no output is generated.
     Otherwise, the time zone name based on the TZ environment variable
     is used.
`%%'
     A single character, ``%''.
*Returns*
When the formatted time takes up no more than MAXSIZE characters, the
result is the length of the formatted string.  Otherwise, if the
formatting operation was abandoned due to lack of room, the result is
`0', and the string starting at S corresponds to just those parts of
`*FORMAT' that could be completely filled in within the MAXSIZE limit.
*Portability*
ANSI C requires `strftime', but does not specify the contents of `*S'
when the formatted string would require more than MAXSIZE characters.
   `strftime' requires no supporting OS subroutines.