Interesting format specifiers
Some, imho, interesting strftime
format specifiers are;
Format specifier | Possible result | Comment |
%T | 12:16:18 | ISO 8601 shorthand for HH:MM:SS, equivalent to %H:%M:%S |
%F | 2019-09-22 | Equivalent to %Y-%m-%d |
%y | 19 | Year with 2 digits |
%Y | 2019 | Year with 4 digits |
%m | 03 | Two digit month |
%d | 07 | Two digit day of month |
%H / %I | 17 / 05 | Two digit Hour. %H is 24 hours, %I 12 hours. (Use %p for AM and PM ) |
%M | 18 | Two digit Minute |
%R | 17:18 | Same as %H:%M |
%S | 09 | Two digit second. Note: 60 is possible because of leap seconds. |
%s | 1607924497 | Unix time, not available on Windows |
%c | Sun Sep 22 12:16:18 2019 | |
%z | +01:00 | Time zone |
%C | 20 | Century number (trunc(year/100) ) |
glibc extensions
glibc extends %m
, %d
, %s
, %H
, %M
(and others?) so that a minus sign can be placed after the %
in order to omit a leading zero: (%-m %-d %-S
).