Formats a time into a string.
size_t strftime (char * buffer, size_t maxlen, char * format, struct tm * timep);
Required Header |
<time.h> |
Return Value
This function returns the number of characters that were copied to the buffer, including the null-terminator.
Parameters
buffer
A pointer to the result buffer
maxlen
The maximum number of characters to store in the buffer
format
The string which specifies how the time is to be formatted
timep
A pointer to the time structure to be converted to a string
Remarks
The strftime function formats the contents of the time structure refered to by timep using the format string and places no more than maxlen characters of the result in buffer.
The function returns a partial buffer if there was not enough space to copy the entire time string.The format string is copied into buffer except when a special character is specified, which is replaced as follows:
A # flag may preceed any format code, but effects only some formats as follows:
%a Abbreviated weekday name
%A Full weekday name
%b Abbreviated month name
%B Full month name
%c Date and time representation appropriate for timezone
%d Day of month as decimal number (01 - 31)
%H Hour in 24-hour format (00 - 23)
%I Hour in 12-hour format (01 - 12)
%j Day of year as decimal number (001 - 366)
%m Month as decimal number (01 - 12)
%M Minute as decimal number (00 - 59)
%p Current timezone's A.M./P.M. indicator for 12-hour clock
%S Second as decimal number (00 - 59)
%U Week of year as decimal number, with Sunday as first day of week (00 - 53)
%w Weekday as decimal number (0 - 6; Sunday is 0)
%W Week of year as decimal number, with Monday as first day of week (00 - 53)
%x Date representation for current timezone
%X Time representation for current timezone
%y Year without century, as decimal number (00 - 99)
%Y Year with century, as decimal number
%z, %Z Time-zone name or abbreviation; no characters if the time zone is unknown
%% Percent sign
%#c long version of date and time
%#x long version of date
Numeric formats will have leading zeros removed (if any.)