添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
duancilan5124 2018-09-04 00:32
浏览 1198
已采纳

如何在Go中将时间戳格式化为GMT?

I need to format a timestamp with RFC2616, the standard for HTTP dates. However, the standard says:

All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception.

From a little digging GMT and UTC are not the same thing. Is there a proper way to convert a timestamp to GMT in Go?

0

1 条回答 默认 最新

  • duanchi8836 2018-09-04 00:38
    关注

    Use the http.TimeFormat layout to format times for HTTP headers. This layout assumes a time in the UTC location.

     s := t.UTC().Format(http.TimeFormat)
    

    If the time is known to be in UTC, then the call to UTC() can be skipped:

     s := t.Format(http.TimeFormat)
        
    本回答被题主选为最佳回答 , 对您是否有帮助呢? 本回答被专家选为最佳回答 , 对您是否有帮助呢? 本回答被题主和专家选为最佳回答 , 对您是否有帮助呢?
    按下Enter换行,Ctrl+Enter发表内容
查看更多回答(0条)

报告相同问题?

悬赏问题

  • ¥50 通过adb命令打开开发者选项中的display cutout java中用poi解析word和exce ,拿不到插入的附件的data 格点数据和站点数据的SVD数据处理 Debezium同步Oracle数据,更新事件只有更新的字段有值,其他字段全是null,导致同步到PG失败? 关于#windows#的问题:未检测到kinect for windows v2传感器(语言-c#) 咨询bilbil上这个视频音字同步的效果用什么软件可实现? 西门子plc6ES7217-1AG40-0XB0怎么rs485通讯呀! matlab有svec这个函数吗?