date --help
%% | 一个文字的 % |
%a | 当前locale 的星期名缩写(例如: 日,代表星期日) |
%A | 当前locale 的星期名全称 (如:星期日) |
%b | 当前locale 的月名缩写 (如:一,代表一月) |
%B | 当前locale 的月名全称 (如:一月) |
%c | 当前locale 的日期和时间 (如:2005年3月3日 星期四 23:05:25) |
%C | 世纪;比如 %Y,通常为省略当前年份的后两位数字(例如:20) |
%d | 按月计的日期(例如:01) |
%D | 按月计的日期;等于%m/%d/%y |
%e | 按月计的日期,添加空格,等于%_d |
%F | 完整日期格式,等价于 %Y-%m-%d |
%g | ISO-8601 格式年份的最后两位 (参见%G) |
%G | ISO-8601 格式年份 (参见%V),一般只和 %V 结合使用 |
%h | 等于%b |
%H | 小时(00-23) |
%I | 小时(00-12) |
%j | 按年计的日期(001-366) |
%k | hour, space padded ( 0..23); same as %_H |
%l | hour, space padded ( 1..12); same as %_I |
%m | month (01..12) |
%M | minute (00..59) |
%n | a newline |
%N | nanoseconds (000000000..999999999) |
%p | locale's equivalent of either AM or PM; blank if not known |
%P | like %p, but lower case |
%q | quarter of year (1..4) |
%r | locale's 12-hour clock time (e.g., 11:11:04 PM) |
%R | 24-hour hour and minute; same as %H:%M |
%s | seconds since 1970-01-01 00:00:00 UTC |
%S | 秒(00-60) |
%t | 输出制表符 Tab |
%T | 时间,等于%H:%M:%S |
%u | 星期,1 代表星期一 |
%U | 一年中的第几周,以周日为每星期第一天(00-53) |
%V | ISO-8601 格式规范下的一年中第几周,以周一为每星期第一天(01-53) |
%w | 一星期中的第几日(0-6),0 代表周一 |
%W | 一年中的第几周,以周一为每星期第一天(00-53) |
%x | 当前locale 下的日期描述 (如:12/31/99) |
%X | 当前locale 下的时间描述 (如:23:13:48) |
%y | 年份最后两位数位 (00-99) |
%Y | 年份 |
%z +hhmm | 数字时区(例如,-0400) |
%:z +hh:mm | 数字时区(例如,-04:00) |
%::z +hh:mm:ss | 数字时区(例如,-04:00:00) |
%:::z | 数字时区带有必要的精度 (例如,-04,+05:30) |
%Z | 按字母表排序的时区缩写 (例如,EDT) |
http://www.cplusplus.com/reference/ctime/strftime/
specifier | Replaced by | Example |
---|---|---|
%a | Abbreviated weekday name * | Thu |
%A | Full weekday name * | Thursday |
%b | Abbreviated month name * | Aug |
%B | Full month name * | August |
%c | Date and time representation * | Thu Aug 23 14:55:02 2001 |
%C | Year divided by 100 and truncated to integer (00-99) | 20 |
%d | Day of the month, zero-padded (01-31) | 23 |
%D | Short MM/DD/YY date, equivalent to %m/%d/%y | 08/23/01 |
%e | Day of the month, space-padded ( 1-31) | 23 |
%F | Short YYYY-MM-DD date, equivalent to %Y-%m-%d | 2001-08-23 |
%g | Week-based year, last two digits (00-99) | 01 |
%G | Week-based year | 2001 |
%h | Abbreviated month name * (same as %b) | Aug |
%H | Hour in 24h format (00-23) | 14 |
%I | Hour in 12h format (01-12) | 02 |
%j | Day of the year (001-366) | 235 |
%m | Month as a decimal number (01-12) | 08 |
%M | Minute (00-59) | 55 |
%n | New-line character ('\n') | |
%p | AM or PM designation | PM |
%r | 12-hour clock time * | 02:55:02 pm |
%R | 24-hour HH:MM time, equivalent to %H:%M | 14:55 |
%S | Second (00-61) | 02 |
%t | Horizontal-tab character ('\t') | |
%T | ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S | 14:55:02 |
%u | ISO 8601 weekday as number with Monday as 1 (1-7) | 4 |
%U | Week number with the first Sunday as the first day of week one (00-53) | 33 |
%V | ISO 8601 week number (01-53) | 34 |
%w | Weekday as a decimal number with Sunday as 0 (0-6) | 4 |
%W | Week number with the first Monday as the first day of week one (00-53) | 34 |
%x | Date representation * | 08/23/01 |
%X | Time representation * | 14:55:02 |
%y | Year, last two digits (00-99) | 01 |
%Y | Year | 2001 |
%z | ISO 8601 offset from UTC in timezone (1 minute=1, 1 hour=100),If timezone cannot be determined, no characters | +100 |
%Z | Timezone name or abbreviation *,if timezone cannot be determined, no characters | CDT |
%% | A % sign | % |