欢迎访问Ningto's博客

Menu
  • 首页
  • 归档
  • 关于
  • 书签
  • 必应壁纸
  • IT聚合
  • 工具
    • 我的工具列表
    • 我的网盘
    • 必应每日壁纸API
    • Html转Markdown
    • 仙尘光标
Menu

gorm写入数据库后时间差8小时

最后更新 2021-03-19 11:01:07   阅读量 1907

这个很明显是时区的问题,首先检查一下数据库连接的uri,是否包含如下参数:

parseTime=true&loc=Local

重新连接数据库就可以了,如果还不行那你可能要看一下系统环境设置了。

官方文档链接

loc
Type:           string
Valid Values:   <escaped name>
Default:        UTC
Sets the location for time.Time values (when using parseTime=true). "Local" sets the system's location. See time.LoadLocation for details.

Note that this sets the location for time.Time values but does not change MySQL's time_zone setting. For that see the time_zone system variable, which can also be set as a DSN parameter.
(转载本站文章请注明作者和出处:泞途 - ningto.com)

下一篇 – Qt QTextEdit文本高亮
上一篇 – Golang pipeline模式

  1. Go

toningto@outlook.com

标签云

Life Android Javascript Python Windows Product Go Tools Java MQ Qt Node.js Tips Shell Design MongoDB Others Mac Mobile React C/C++ Web Boost Linux IOS Bug Database

推广链接

【腾讯云】云产品限时秒杀,爆款1核2G云服务器,首年99元

多谢支持,用了好几年,服务很稳定支持多设备!

其他

文章RSS

Copyright © 2016 Welcome To Ningto Blog | 鄂ICP备17003086号-2