2

I am trying to parse a date value that I read from another file. The format of the string is:

str := 2019-04-29 11:16:06.699920+0900
layout := "2006-01-02 15:04:05.000000Z"

t, err := time.Parse(layout, str)
// handle error

I get an error saying that +0900 cannot be parsed as Z. I tried using the following layout as well:

layout := "2006-01-02 15:04:05.000000+0000"

I can parse the datetime if I replace +0900 with Z but I don't want to lose the timezone. How can I parse the date of such format, keeping the timezone intact? Thanks.

EDIT: Parsing date string in Go has a good discussion on the layout used but doesn't address the alternatives to using Z that I needed.

Replacing Z with -0700 did the job.

su619
  • 35
  • 5

0 Answers0