当我使用 Hour() 函数时,它会一直返回 UTC 小时。如何获得指定时区的正确小时数?谢谢!
1 回答
呼啦一阵风
TA贡献1802条经验 获得超6个赞
只需使用In()功能,它应该工作。例如:
package main
import (
"fmt"
"time"
)
func main() {
loc, _ := time.LoadLocation("Europe/Berlin")
t := time.Now().In(loc)
fmt.Println(t.Hour())
}
- 1 回答
- 0 关注
- 121 浏览
添加回答
举报
0/150
提交
取消
