It seems that gorm is converting local times to UTC when writing to my database but the time object in golang has the correct timezone and the field is a timestamp with time zone. Is this expected behavior?
Something like this ...
timezone, _ := time.LoadLocation("Europe/Berlin")
future := time.Now().In(timezone).Add(24 * time.Hour)
log.Printf("future: %+v", future)
streak.ExpiresAt = &future
conn.Debug().Omit(clause.Associations).Save(&streak)
This outputs:
future: 2022-09-22 00:00:00 +0200 CEST
And the query
UPDATE "lesson_streaks" SET "user_id"='34193e38-1e61-11ed-8941-8a6a814de1b1',"expires_at"='2022-09-22 00:00:00' WHERE "id" = 'c17dcc04-28e2-11ed-a750-8a6a814de1b1'
So it's converting to UTC but I want this is the local timezone because it's a future event and if the UTC offset changes during a daylight savings event, it will be inaccurate.
Comment From: tamoyal
I'm still having issues getting the gorm playground up and running
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: li-jin-gou
@tamoyal Here you need to modify the DSN configuration,refer to https://github.com/go-sql-driver/mysql#loc if use mysql
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨