-4

I have format string "day/month/year, hour:minute:second"

How do I parse into a time object?

I tried:

const longForm = "5/01/2015, 12:00:00"

t1, _ := time.Parse(longForm, "5/01/2015, 12:00:00") 

0001-01-01 00:00:00 +0000 UTC

I get some UTC time, but this is not helpful if I want to compare times because I get the same UTC time for them all. Any help?

wwjdm
  • 2,568
  • 7
  • 32
  • 61

1 Answers1

3

Rule #1 of fightclub, err Go, check your errors.

That being said, the format for time parsing is defined in the documentation (scroll down to constants).

For your specific question, the format is 1/_2/2006, 15:04:05.

playground

OneOfOne
  • 95,033
  • 20
  • 184
  • 185