Declaration:
size_t strftime(char * str,
size_t maxsize, const char * format,
const struct tm * timeptr);
Formats the time represented in the structure timeptr
according to the formatting rules defined in format and stored
into str. No more than maxsize characters are stored into str
(including the terminating null character).
All characters in the format string are copied to the str
string, including the terminating null character, except for
conversion characters. A conversion character begins with the
% sign and is followed by another character
which defines a special value that it is to be replaced by.
Conversion
Character |
What it is replaced by |
%a |
abbreviated weekday name |
%A |
full weekday name |
%b |
abbreviated month name |
%B |
full month name |
%c |
appropriate date and time
representation |
%d |
day of the month (01-31) |
%H |
hour of the day (00-23) |
%I |
hour of the day (01-12) |
%j |
day of the year (001-366) |
%m |
month of the year (01-12) |
%M |
minute of the hour (00-59) |
%p |
AM/PM designator |
%S |
second of the minute (00-61) |
%U |
week number of the year where Sunday
is the first day of week 1 (00-53) |
%w |
weekday where Sunday is day 0 (0-6) |
%W |
week number of the year where Monday
is the first day of week 1 (00-53) |
%x |
appropriate date representation |
%X |
appropriate time representation |
%y |
year without century (00-99) |
%Y |
year with century |
%Z |
time zone (possibly abbreviated) or
no characters if time zone isunavailable |
%% |
% |
Returns the number of characters stored into str not
including the terminating null character. On error zero is
returned. |