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

Taught in

References