Format and Parse use example-based layouts. Layouts must use the reference time Mon Jan 2 15:04:05 MST 2006:
The example time must be exactly as shown: the year 2006, 15 for the hour, Monday for the day of the week, etc. This is how Go knows which part of the pattern represents which component.
fmt.Println(t.Format("3:04PM"))// Output: 10:15AMfmt.Println(t.Format("Mon Jan _2 15:04:05 2006"))// Output: Tue Mar 3 10:15:30 2026fmt.Println(t.Format("2006-01-02T15:04:05.999999-07:00"))// Output: 2026-03-03T10:15:30.123456+00:00
_, err := time.Parse("Mon Jan _2 15:04:05 2006", "8:41PM")fmt.Println(err)// Output: parsing time "8:41PM" as "Mon Jan _2 15:04:05 2006": cannot parse "8:41PM" as "Mon"