美文网首页Go我爱编程
golang 时间转换,不注意将引发Gorm等mysql操作保存

golang 时间转换,不注意将引发Gorm等mysql操作保存

作者: 承诺一时的华丽 | 来源:发表于2018-08-07 16:09 被阅读2次
time.Parse("2006-01-02 15:04:05", "2017-06-20 18:16:15")
默认是没有时区
local, _ := time.LoadLocation("Local")
now, _ := time.ParseInLocation("2006-01-02 15:04:05", "2017-06-20 18:16:15", local)
需要指定时区,再保存的时候才不会出现8小时差的情况

相关文章

网友评论

    本文标题:golang 时间转换,不注意将引发Gorm等mysql操作保存

    本文链接:https://www.haomeiwen.com/subject/xhdavftx.html