strftime---flexible calendar time formatter
#include <time.h> size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *timp);
strftime converts a
struct tm representation of the time (at
timp) into a string, starting at s and occupying no more than
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:
Mon Apr 01 13:13:13 1992
001' to `
AM' or `
PM' as appropriate.
00' to `
53'; week number 1 is taken as beginning with the first Sunday in a year). See also
%U', but counting week 1 as beginning with the first Monday in a year.
Mon Apr 01 1992
%Z' but generates no output for it).
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
*format that could be completely filled in within the
ANSI C requires
strftime, but does not specify the contents of
*s when the formatted string would require more than
strftime requires no supporting OS subroutines.
Go to the first, previous, next, last section, table of contents.