The reference time has -0700
time zone. Quoting from time.Parse()
:
Parse parses a formatted string and returns the time value it represents. The layout defines the format by showing how the reference time, defined to be
Mon Jan 2 15:04:05 -0700 MST 2006
would be interpreted if it were the value; it serves as an example of the input format. The same interpretation will then be made to the input string.
With this change it works:
date := "2020-12-23T16:39:24.362+06:00"
t, err := time.Parse("2006-01-02T15:04:05.000-07:00", date)
fmt.Println(err)
fmt.Printf("t = %s", t)
And outputs (try it on the Go Playground):
<nil>
t = 2020-12-23 16:39:24.362 +0600 +0600
t, _ := time.Parse(time.RFC3339, date)
- docs