Golang时间戳解析

时间:2016-10-13 10:51:36

标签: go

我尝试使用以下代码解析时间戳Oct 12 2016 13:59:27 UTC

eventDateLayout := "Jan _2 2006 15:04:00 UTC"
eventCheckDate, _ := time.Parse(eventDateLayout,"Oct 12 2016 13:59:27 UTC")
fmt.Println(eventCheckDate)

如果0001-01-01 00:00:00 +0000 UTC不是预期的结果。

这个时间戳可以用golang时间库解析吗?

1 个答案:

答案 0 :(得分:1)

除了错误的时间布局外,我建议处理错误而不是丢弃它。

它为您提供了一个有用的错误消息,可用于高效调试:

cannot parse "27 UTC" as ":00 UTC"

Go playground (note the outputted time will be different)

相关问题