Home > other >  How do I parse the following time in Golang?
How do I parse the following time in Golang?

Time:01-17

What does the layout for parse look like for this timestamp 2021-10-07 12:44:22 0530? I've tried all combinations and still can't seem to get it right! Thanks for all your help!

Btw, this format is generated by a Ruby client (speaking to the Go HTTP Server).

CodePudding user response:

Use the format string "2006-01-02 15:04:05 -0700" to parse the time in the question:

t, err := time.Parse("2006-01-02 15:04:05 -0700", "2021-10-07 12:44:22  0530")

Run an example on Go's playground.

  •  Tags:  
  • Related