strftime()函数中的格式字符

来源:互联网 发布:怎么查电脑的mac地址 编辑:程序博客网 时间:2024/05/16 13:55

time.h中的strftime函数用于把struct tm转换为字符串输出,类似于printf,我们可以为其指定格式,下表是其使用的格式字符

 

来源:http://www.cplusplus.com/reference/clibrary/ctime/strftime/

specifierReplaced byExample%aAbbreviated weekday name *Thu%AFull weekday name *Thursday%bAbbreviated month name *Aug%BFull month name *August%cDate and time representation *Thu Aug 23 14:55:02 2001%dDay of the month (01-31)23%HHour in 24h format (00-23)14%IHour in 12h format (01-12)02%jDay of the year (001-366)235%mMonth as a decimal number (01-12)08%MMinute (00-59)55%pAM or PM designationPM%SSecond (00-59)02%UWeek number with the first Sunday as the first day of week one (00-53)33%wWeekday as a decimal number with Sunday as 0 (0-6)4%WWeek number with the first Monday as the first day of week one (00-53)34%xDate representation *08/23/01%XTime representation *14:55:02%yYear, last two digits (00-99)01%YYear2001%ZTimezone name or abbreviationCDT%%% sign%* The specifiers whose description is marked with an asterisk (*) are locale-dependent.

 

 

原创粉丝点击