duanming7961
2019-02-06 11:05
浏览 442
已采纳

如何在Go中构造time.Time与时区偏移

This is an example date from an Apache log:

[07/Mar/2004:16:47:46 -0800]

I have successfully parsed this into year(int), month(time.Month), day(int), hour(int), minute(int), second(int), and timezone(string).

How can I construct time.Time such that it includes the -0800 time zone offset?

This is what I have so far:

var nativeDate time.Time
nativeDate = time.Date(year, time.Month(month), day, hour, minute, second, 0, ????)

What should I use in place of ????? time.Local or time.UTC is not appropriate here.

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

这是来自Apache日志的示例日期:</ p>

   [07 / Mar / 2004:16:47:46 -0800] 
 </ code> </ pre> 
 
 

我已成功将其解析为year(int),month(time.Month), day(int),hour(int),minute(int),second(int)和timezone(string)。</ p>

如何构造时间。时间应包含< code> -0800 </ code>时区偏移量?</ p>

这是我到目前为止的信息:</ p>

  var nativeDate time.Time  
nativeDate = time.Date(年,时,月(月),日,时,分,秒,0,????)
 </ code> </ pre> 
 
 

应该 我用 ???? </ code>代替? time.Local </ code>或 time.UTC </ code>在这里不合适。</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题