Strftime
Syntax:
#include <time.h> size_t strftime( char *str, size_t maxsize, const char *fmt, struct tm *time ); |
Function: The function is based on parameters.FMTSet the formatTimeType parameters are formatted as date and time information and stored in stringsStrMedium (upMaxsizeCharacters ). The code used to set different time types is:
Code |
Description |
% |
Scaling form of the week |
% |
Complete Form of week |
% B |
Scaling form of month |
% B |
Complete month format |
% C |
Scaling form of month |
% D |
The day of the month (1-31) |
% H |
Hour, in 24-hour format (0-23) |
% I |
Hour, 12-hour format (1-12) |
% J |
The day of the year (1-366) |
% M |
Month (1-12 ).Note:In some versions of Microsoft Visual C ++, the value range may be 0-11. |
% M |
Minutes (0-59) |
% P |
AM or PM of local time) |
% S |
Seconds (0-59) |
% U |
The week of the year, and Sunday is the first day of the week. |
% W |
Number of the day of the week (0-6, Sunday = 0) |
% W |
The week of the year, and Sunday is the first day of the week. |
% X |
Standard date string |
% X |
Standard Time string |
% Y |
Year (0-99) |
% Y |
Year in ccyy format (for example, 2004) |
% Z |
Time zone name |
% |
Percent sign |
The strftime () function returns a processing result string.StrThe number of characters in. If an error occurs, zero is returned.