reference time layout
Go's way of describing a date format by writing one fixed example moment, 2006-01-02 15:04:05, in the shape you want.
In more detail
Instead of codes like %Y, you write how that specific moment should look, such as 2006-01-02 for a date or 15:04 for hours and minutes. It looks odd at first, so prefer the ready-made constants such as time.RFC3339. Format turns a time.Time into text and time.Parse does the reverse.
Example
t.Format("2006-01-02")Related terms
- RFC 3339 — The internet standard timestamp format, such as 2025-01-02T03:04:05Z, that machines and people can both read without ambiguity.
- time package — Go's standard library package for moments, durations, timers and formatting dates, built around the time.Time and time.Duration types.
- UTC — Coordinated Universal Time, the worldwide reference time that does not change with seasons or time zones.
Taught in
- The time Package — Concurrent Systems Programming with Go