我正在嘗試在 Go 中使用 Time 包來提取時間詳細(xì)信息,如下所示。我已經(jīng)能夠成功解析年、月、日、小時、分鐘和秒等值。不幸的是,當(dāng)我嘗試使用 Zone 來提取偏移量時,我似乎得到了不正確的偏移量。當(dāng)我嘗試查看我的時間對象時,我看到兩個偏移條目,不確定我做錯了什么。 serverTime := "2021-10-31T22:17:03.996-0700" fmt.Println("Server time is: ", serverTime) t, _ := time.Parse("2006-01-02T15:04:05.999-0700", serverTime) zone, offset := t.Zone() fmt.Println("Printing time object: ",t) fmt.Println("Year", t.Year()) fmt.Println("Month", t.Month().String()) fmt.Println("Date", t.Day()) fmt.Println("Hour", t.Hour()) fmt.Println("Minutes", t.Minute()) fmt.Println("Seconds",t.Second()) fmt.Println("Zone:", zone) fmt.Println("Offset", offset)偏移量的輸出是:偏移量-25200,我希望它是-0700這是游樂場的鏈接
1 回答

長風(fēng)秋雁
TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超7個贊
- 1 回答
- 0 關(guān)注
- 135 瀏覽
添加回答
舉報(bào)
0/150
提交
取消