This is a created article in which the information may have evolved or changed.
When you deploy a PHP project, add a line to the PHP portal file:
date_default_timezone_set('PRC');
Time formatted output the time zone for the East Eight zone in Beijing time without the need for a relational system in the time zone.
In the go language, the go language time. Now () returns the time in the local time zone, directly using:
time.Now().Format("2006-01-02 15:04:05")
The time in the local time zone is output.
The go language does not have a global settings time zone such a thing, each output time needs to call an in () function to change the time zone:
var cstSh, _ = time.LoadLocation("Asia/Shanghai") //上海fmt.Println("SH : ", time.Now().In(cstSh).Format("2006-01-02 15:04:05"))
On Windows systems, time is not installed on the go locale. Loadlocation will fail to load.
var cstZone = time.FixedZone("CST", 8*3600) // 东八fmt.Println("SH : ", time.Now().In(cstZone).Format("2006-01-02 15:04:05"))
The best way is to use time. Fixedzone