服务器版本及gorm包:
❯ docker exec -it mysql mysqld --version
mysqld Ver 5.7.29 for Linux on x86_64 (MySQL Community Server (GPL))
❯ docker exec -it mysql mysql --version
mysql Ver 14.14 Distrib 5.7.29, for Linux (x86_64) using EditLine wrapper
import "github.com/jinzhu/gorm"
两张表:
mysql> desc t1;
+------------+-------------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------------+------+-----+-------------------+----------------+
| ... | | | | | |
| created_at | timestamp | YES | | CURRENT_TIMESTAMP | |
+------------+-------------------+------+-----+-------------------+----------------+
mysql> desc t2;
+----------------+------------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------+------+-----+-------------------+----------------+
| ... | ... | ... | ... | ... | ... |
| initiated_at | timestamp | YES | | CURRENT_TIMESTAMP | |
+----------------+------------------+------+-----+-------------------+----------------+
gorm定义时的模型如下stuct{}:
// t1
type T1 struct {
ID uint `gorm:"primary_key"`
// others are here
// ...
期待:
请注意,我位于asia/dhaka(+06:00) 区域。created_at表的时间t1是我所在地区的BST当前时间。另一方面,表的时间initiated_at是t2UTC当前时间。
但我希望这两个时间是相同的(我的意思是 UTC 或 BST)。
想知道:
之所以两次的地域不同。
任何解决方案,使两个时间都在同一区域
MYYA
相关分类