%a
- Abbreviated weekday name in the current locale. (Also matches full name on input.)
%A
- Full weekday name in the current locale. (Also matches abbreviated name on input.)
%b
- Abbreviated month name in the current locale. (Also matches full name on input.)
%B
- Full month name in the current locale. (Also matches abbreviated name on input.)
%c
- Date and time, locale-specific.
%d
- Day of the month as decimal number (01–31).
%H
- Hours as decimal number (00–23).
%I
- Hours as decimal number (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
- AM/PM indicator in the locale. Used in conjuction with
%I
and not with%H
. %S
- Second as decimal number (00–61), allowing for up to two leap-seconds (but POSIX-compliant OSes will ignore leap seconds).
%U
- Week of the year as decimal number (00–53) using the first Sunday as day 1 of week 1.
%w
- Weekday as decimal number (0–6, Sunday is 0).
%W
- Week of the year as decimal number (00–53) using the first Monday as day 1 of week 1.
%x
- Date, locale-specific.
%X
- Time, locale-specific.
%y
- Year without century (00–99). If you use this on input, which century you get is system-specific. So don’t! Often values up to 69 (or 68) are prefixed by 20 and 70(or 69) to 99 by 19.
%Y
- Year with century.
%z
- (output only.) Offset from Greenwich, so
-0800
is 8 hours west of Greenwich. %Z
- (output only.) Time zone as a character string (empty if not available).
Where leading zeros are shown they will be used on output but are optional on input.
Also defined in the current standards but less widely implemented (e.g. not for output on Windows) are
%C
- Century (00–99): the integer part of the year divided by 100.
%D
- Locale-specific date format such as
%m/%d/%y
: ISO C99 says it should be that exact format. %e
- Day of the month as decimal number ( 1–31), with a leading space for a single-digit number.
%F
- Equivalent to %Y-%m-%d (the ISO 8601 date format).
%g
- The last two digits of the week-based year (see
%V
). (Typically accepted but ignored on input.) %G
- The week-based year (see
%V
) as a decimal number. (Typically accepted but ignored on input.) %h
- Equivalent to
%b
. %k
- The 24-hour clock time with single digits preceded by a blank.
%l
- The 12-hour clock time with single digits preceded by a blank.
%n
- Newline on output, arbitrary whitespace on input.
%r
- The 12-hour clock time (using the locale’s AM or PM).
%R
- Equivalent to
%H:%M
. %t
- Tab on output, arbitrary whitespace on input.
%T
- Equivalent to
%H:%M:%S
. %u
- Weekday as a decimal number (1–7, Monday is 1).
%V
- Week of the year as decimal number (00–53). If the week (starting on Monday) containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. (Typically accepted but ignored on input.)