formatstring
The output time format, which can be a predefined format or a custom layout.
## Predefined Formats
`RFC3339nano`, `Kitchen`, `StampMilli`, `Rubydate`, `RFC822`, `RFC1123`, `Stamp`, `StampMicro`, `StampNano`, `TimeOnly`, `Unixdate`, `RFC822z`, `RFC850`, `ANSIC`, `RFC1123z`, `RFC3339`, `DateTime`, `DateOnly`
## Custom Format
A custom format can be built using the following components. Each component shows an example of how a part of the reference time is formatted. Only these values are recognized. Any text in the layout string that is not a recognized component will be treated as a literal.
- Year: "2006", "06"
- Month: "Jan", "January", "01", "1"
- Day of the week: "Mon", "Monday"
- Day of the month: "2", "_2", "02"
- Day of the year: "__2", "002"
- Hour: "15", "3", "03" (PM or AM)
- Minute: "4", "04"
- Second: "5", "05"
- AM/PM mark: "PM"
### Numeric Time Zone Offsets
- "-0700" (±hhmm)
- "-07:00" (±hh:mm)
- "-07" (±hh)
- "-070000" (±hhmmss)
- "-07:00:00" (±hh:mm:ss)
Replacing the sign with a "Z" triggers ISO 8601 behavior, which prints "Z" for the UTC zone:
- "Z0700" (Z or ±hhmm)
- "Z07:00" (Z or ±hh:mm)
- "Z07" (Z or ±hh)
- "Z070000" (Z or ±hhmmss)
- "Z07:00:00" (Z or ±hh:mm:ss)
Within the format string, the underscores in "_2" and "__2" represent spaces that may be replaced by digits if the following number has multiple digits, for compatibility with fixed-width Unix time formats. A leading zero represents a zero-padded value.
The formats __2 and 002 are space-padded and zero-padded three-character day of year; there is no unpadded day of year format.
### Fractional Seconds
A comma or decimal point followed by one or more zeros represents a fractional second, printed to the given number of decimal places. A comma or decimal point followed by one or more nines represents a fractional second with trailing zeros removed.
For example, "15:04:05.000" formats or parses with millisecond precision.
timezonestring
The target timezone for the output, in IANA format (e.g., 'America/New_York').