Go time layout tokens.
Go has no tokens at all: you write the reference time itself — Mon Jan 2 15:04:05 MST 2006 — laid out the way you want your output to look, and the formatter pattern-matches your layout against it. The mnemonic is that the fields count 1 through 7 (month 1, day 2, hour 3, minute 4, second 5, year 6, zone 7). Names always render in English; there is no locale support in the standard library. There are no tokens for week numbers, quarters or eras.
| Token | Means | Example |
|---|---|---|
| 2006 | Four-digit year | 2006 |
| 06 | Two-digit year | 06 |
| 1 | Month number | 1 |
| 01 | Month number, padded | 01 |
| Jan | Month name, abbreviated | Jan |
| January | Month name, full | January |
| 2 | Day of month | 2 |
| 02 | Day of month, padded | 02 |
| 002 | Day of year Zero-padded to three digits; __2 gives the space-padded form. Added in Go 1.13. | 2 |
| Mon | Weekday, abbreviated | Mon |
| Monday | Weekday, full | Monday |
| 15 | Hour, 24-hour clock, padded Always zero-padded; Go has no unpadded 24-hour token. | 15 |
| 3 | Hour, 12-hour clock | 3 |
| 03 | Hour, 12-hour clock, padded | 03 |
| PM | AM/PM marker Write pm for lowercase output. | PM |
| 04 | Minute, padded A bare 4 gives the unpadded minute. | 04 |
| 05 | Second, padded A bare 5 gives the unpadded second. | 05 |
| .000 | Fractional seconds Prints exactly as many digits as you write zeros; .999 trims trailing zeros instead. | 000 |
| -0700 | UTC offset, basic | -0700 |
| -07:00 | UTC offset, extended | -07:00 |
| MST | Time-zone name, short | MST |
Examples render the reference instant, Mon, Jan 2 2006, 3:04:05 PM MST.
Literal text
No escaping exists. Any text that doesn't match a reference-time fragment passes through literally — which means literal text that LOOKS like a fragment (a lone 1, or the word Jan) will be treated as a field. There is no way to escape it; restructure the string instead.
Verified against Go standard library — time package constants.