我对当前时区有些迷惑。我想得到它的完整代表。说,我有MSK。如何获得“欧洲/莫斯科”,这是Ubuntu中“cat/etc/timezone”的结果? Google搜索了很多,尝试了很多例子,但是没有找到...
最佳答案
正如Peter所说,标准库中没有用于此的东西,但是如果您知道您的应用程序将始终在Linux上运行,则可以使用os.Exec
例如:
tz := "MSK"
out, err := exec.Command("grep", tz, "/etc/timezone").Output()
if err != nil {
log.Fatal(err)
}
fmt.Printf("The %s timezone is %s\n", tz, out)
关于datetime - 在Go中获取当前时区ID,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60508311/