created_at (datetime) gets stored in UTC with go-sql-driver/mysql
Environment
- go-sql-driver/mysql version 1.2
Conclusion
Set parseTime=true and loc=Asia%2FTokyo as shown below.
1 | db, err := sql.Open("mysql", "user:passward@/dbname?parseTime=true&loc=Asia%2FTokyo") |
When loc=xxxx is not specified, local is used, and even if you pass time.Now() to a datetime column on INSERT, it gets rewritten to UTC time.
This one tripped me up for a bit.
created_at (datetime) gets stored in UTC with go-sql-driver/mysql
https://kenzo0107.github.io/en/2015/08/19/gosql-driver-mysql-created_at-utc/
