GO:GO中的日期和时间解析[重复]

This question already has an answer here:

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?

</div>

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