当前位置:网站首页>Golang foundation - the time data inserted by golang into MySQL is inconsistent with the local time
Golang foundation - the time data inserted by golang into MySQL is inconsistent with the local time
2022-07-05 08:50:00 【The hunter is eating meat】
Problem description
golang towards mysql When inserting the data of the time field , The time value before insertion is correct , After inserting , In the database Time value Than Time value before insertion Less 8 Hours .
analysis
Default time zone and Caused by inconsistent local time zones .
analytic method
database URL Add... After configuration parseTime=true&loc=Local
Parameters can be solved .
func init() {
Db, err = sql.Open("mysql", "root:[email protected](localhost:3306)/testDB?parseTime=true&loc=Local")
if err != nil {
panic(err.Error())
}
}
边栏推荐
- Basic number theory - fast power
- Guess riddles (6)
- 猜谜语啦(4)
- JS asynchronous error handling
- 696. 计数二进制子串
- Explore the authentication mechanism of StarUML
- Use and programming method of ros-8 parameters
- Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)
- Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding
- 微信H5公众号获取openid爬坑记
猜你喜欢
随机推荐
696. Count binary substring
资源变现小程序添加折扣充值和折扣影票插件
How can fresh students write resumes to attract HR and interviewers
Tips 1: Web video playback code
Halcon blob analysis (ball.hdev)
Configuration and startup of kubedm series-02-kubelet
Use and programming method of ros-8 parameters
[Niuke brush questions day4] jz55 depth of binary tree
Digital analog 1: linear programming
287. 寻找重复数-快慢指针
Digital analog 2: integer programming
Guess riddles (4)
C语言标准函数scanf不安全的原因
U8g2 drawing
Wheel 1:qcustomplot initialization template
Halcon color recognition_ fuses. hdev:classify fuses by color
Count of C # LINQ source code analysis
Redis实现高性能的全文搜索引擎---RediSearch
696. 计数二进制子串
Guess riddles (8)