I am using gorm with mysql as database with go module like this :
- gorm.io/gorm v1.21.7
- github.com/go-sql-driver/mysql v1.6.0
My system timezone is +07:00 (Asia/Jakarta), and the mysql timezone is using the system timezone itself.
but something wrong happen when I've struct like this
type Name struct {
ID uint64 `gorm:"id;primaryKey;autoIncrement"`
Name string `gorm:"column:name"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
on the mysql table created_at and updated_at declared as DATETIME, when I print the CreatedAt and UpdatedAt value, the timezone is +0000 (UTC), when I'm trying to use the Time.In function I got the wrong value, like I'm converting a time from UTC to +07:00, how can I declare to GORM that I'm using +07:00 as default timezone.