This is a created article in which the information may have evolved or changed.
Recently as a small white in learning golang
, can only say more step on the pit, to better study.
Intend to use Go-web to write practiced hand content.
Encounter a problem with the MySQL time storage time zone.
Using a database migration tool that can be used, the goose MySQL time is in accordance with the time UTC
zone.
As a person with a bit PHP
of experience, it is very simple, change a php.ini configuration, set up a bit date.timezone = PRC
can be solved.
But not familiar with Golang ah, only Google solved.
Goose about operating MySQL This part of the use of go-sql-driver/mysql, found a issue, is reported to have such a bug.
The conclusion is that we are using UTC to save.
Then I think about it, in many cases, the default time zone in the work is in the East eight area, the user is also here, regardless of other time zone situation.
Okay, so how do we solve this problem?
best-way-to-handle-storing-displaying-dates-in-different-timezones-in-php
Save Database using UTC
Remove to use UTC
Depending on the situation, you can turn back or front end to the user's current time zone