donglie1994 2019-06-21 11:48
浏览 294

golang中的时间格式-DayOfyearTHour:Minute.000Z

I want to convert the timestamp to DayOfyearTHour:Minute.000Z in golang. As i am new to golang, can someone help me please

 package main

 import (   "fmt"   "time" )

 func main() {  
        layout := "2006-01-02T15:04:05.000Z"    
        str :="2019-05-10 19:02:27.917 +0000 UTC"   
        t, err := time.Parse(layout, str)

    if err != nil {
            fmt.Println(err)    }   fmt.Println(t)

 }

The below is the error

parsing time "2019-05-10 19:02:27.917 +0000 UTC" as "2006-01-02T15:04:05.000Z": cannot parse " 19:02:27.917 +0000 UTC" as "T"
0001-01-01 00:00:00 +0000 UTC
  • 写回答

1条回答 默认 最新

  • douhensheng1131 2019-07-14 22:21
    关注

    You can see the implementation in this package. If you don't have the chance to upgrade Go version (1.13 is not out yet) you can do it by yourselve!

    BTW: I'm making a series of videos about Golang development. If you like, you guys can add the topics you'd like to get covered by completing this form.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100