The full proleptic Gregorian year, zero-padded to 4 digits.
The proleptic Gregorian year divided by 100, zero-padded to 2 digits.
The proleptic Gregorian year modulo 100, zero-padded to 2 digits.
Month number (01--12), zero-padded to 2 digits.
Abbreviated month name. Always 3 letters.
Full month name. Also accepts corresponding abbreviation in parsing.
Day number (01--31), zero-padded to 2 digits.
Abbreviated weekday name. Always 3 letters.
Full weekday name. Also accepts corresponding abbreviation in parsing.
Sunday = 0, Monday = 1, ..., Saturday = 6.
Monday = 1, Tuesday = 2, ..., Sunday = 7. (ISO 8601)
Week number starting with Sunday (00--53), zero-padded to 2 digits.
Day of the year (001--366), zero-padded to 3 digits.
Month-day-year format. Same as
Locale's date representation (e.g., 12/31/99).
Year-month-day format (ISO 8601). Same as
Day-month-year format. Same as
Hour number (00--23), zero-padded to 2 digits.
Hour number in 12-hour clocks (01--12), zero-padded to 2 digits.
Minute number (00--59), zero-padded to 2 digits.
Second number (00--60), zero-padded to 2 digits.
The fractional seconds (in nanoseconds) since last whole second.
Hour-minute format. Same as
Hour-minute-second format. Same as
Locale's time representation (e.g., 23:13:48).
Hour-minute-second format in 12-hour clocks. Same as
TIME ZONE SPECIFIERS:
Local time zone name. Skips all non-whitespace characters during parsing.
Offset from the local time to UTC (with UTC being
Parsing only: Same as
DATE & TIME SPECIFIERS:
Locale's date and time (e.g., Thu Mar 3 23:05:25 2005).
ISO 8601 / RFC 3339 date & time format.
UNIX timestamp, the number of seconds since 1970-01-01 00:00 UTC.
Literal tab (
Literal newline (
Literal percent sign.
It is possible to override the default padding behavior of numeric specifiers
%?. This is not allowed for other specifiers and will result in the
Suppresses any padding including spaces and zeroes. (e.g.
Uses spaces as a padding. (e.g.
Uses zeroes as a padding. (e.g.
%Y: Negative years are allowed in formatting but not in parsing.
%y: This is floor division, so 100 BCE (year number -99) will print
%U: Week 1 starts with the first Sunday in that year. It is possible to have week 0 for days before the first Sunday.
%V: Week 1 is the first week with at least 4 days in that year. Week 0 does not exist, so this should be used with
%S: It accounts for leap seconds, so
60 is possible.
%f is right-aligned and always zero-padded to 9 digits for the compatibility with glibc and others, so it always counts the number of nanoseconds since the last whole second. E.g. 7ms after the last second will print
007000000, and parsing
7000000 will yield the same.
%.f is left-aligned and print 0, 3, 6 or 9 fractional digits according to the precision. E.g. 70ms after the last second under
%.f will print
.070 (note: not
.07), and parsing
.070000 etc. will yield the same. Note that they can print or read nothing if the fractional part is zero or the next character is not
%.9f are left-aligned and print 3, 6 or 9 fractional digits according to the number preceding
f. E.g. 70ms after the last second under
%.3f will print
.070 (note: not
.07), and parsing
.070000 etc. will yield the same. Note that they can read nothing if the fractional part is zero or the next character is not
. however will print with the specified length.
%9f are left-aligned and print 3, 6 or 9 fractional digits according to the number preceding
f, but without the leading dot. E.g. 70ms after the last second under
%3f will print
070 (note: not
07), and parsing
070000 etc. will yield the same. Note that they can read nothing if the fractional part is zero.
%Z: Offset will not be populated from the parsed data, nor will it be validated. Timezone is completely ignored. Similar to the glibc
strptime treatment of this format code.
It is not possible to reliably convert from an abbreviation to an offset, for example CDT can mean either Central Daylight Time (North America) or China Daylight Time.
%+: Same as
%Y-%m-%dT%H:%M:%S%.f%:z, i.e. 0, 3, 6 or 9 fractional digits for seconds and colons in the time zone offset.
strftime implementations have different (and locale-dependent) formats for this specifier. While Chrono's format for
%+ is far more stable, it is best to avoid this specifier if you want to control the exact output.
%s: This is not padded and can be negative. For the purpose of Chrono, it only accounts for non-leap seconds so it slightly differs from ISO C
Note: This information is from the Rust Documentation for Date and Time Formatting.