go 语言 time 时区问题 疑问


func main() {
	fmt.Println("-----------------")
	t, _ := time.Parse(time.RFC3339, "1876-01-02T15:04:05Z")
	_, err := t.Local().MarshalBinary()
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(t)
	t.In(time.Local)
	fmt.Println(t)
	fmt.Println(t.Local())
	fmt.Println("-----------------")
}

结果

-----------------
Time.MarshalBinary: zone offset has fractional minute
1876-01-02 15:04:05 +0000 UTC
1876-01-02 15:04:05 +0000 UTC
1876-01-02 23:09:48 +0805 LMT
-----------------

为什么时区必须是分钟数的整数倍。
bug 见 https://github.com/golang/go/issues/39616
为什么时区设置了没起作用。
需要赋值给一个新变量。。

本文原创自博客园 地址:https://www.cnblogs.com/Heoric/
我想要知道上帝是如何创造这个世界的。我对这个或那个现象不感兴趣,我要知道的是他的思想。其他都是细节。
原文地址:https://www.cnblogs.com/Heoric/p/15749507.html