dshmkgq558192365
2016-08-05 21:33
浏览 159
已采纳

将UTC字符串转换为时间对象

I have this datetime, or something that looks like it.

2014-11-17 23:02:03 +0000 UTC

I want to convert this to a time object and I've been unable to produce any output from time.Parse apart from:

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

I've tried these layouts:

time.RFC3339
0001-01-01 00:00:00 0000 UTC
2016-10-10
time.UnixDate

And a few more - none have worked.

This is how I'm calling parse :

updatedAt, err := time.Parse(time.UnixDate, updatedAtVar)

How do I create a time object from a string?

图片转代码服务由CSDN问答提供 功能建议

我有这个日期时间或类似的日期时间。</ p>

 <  code> 2014-11-17 23:02:03 +0000 UTC 
 </ code> </ pre> 
 
 

我想将其转换为时间对象,但无法生成任何对象 time.Parse </ code>的输出,除了:</ p>

  0001-01-01 00:00:00 +0000 UTC 
 </ code> </  pre> 
 
 

我尝试过以下布局:</ p>

  time.RFC3339 
0001-01-01 00:00:00 0000 UTC 
2016-10  -10 
time.UnixDate 
 </ code> </ pre> 
 
 

还有一些-没有一个起作用。</ p>

这就是我打电话的方式 parse </ code>:</ p>

  updatedAt,err:= time.Parse(time.UnixDate,updatedAtVar)
 </ code> </ pre> 
  
 

如何从字符串创建时间对象?</ p> </ div>

2条回答 默认 最新

相关推荐 更多相似问题