我被 sntp 的输出困惑了好久,原来这玩意不是时区

193 天前
 phpfpm
$ sntp -c 192.168.0.10
sntp 4.2.8p12@1.3728-o (1)
Can't open KOD db file /var/lib/sntp/kod for writing: Permission denied
2025-02-28 16:31:12.839708 (-0800) +0.0 +/- 0.014694 192.168.0.10 s1 no-leap


我就真的一直很困惑,为啥我的日期时间时区都是对的,给我的结果的时区显示的是-0800 呢?

看了下文档:

The default is to write the estimated correct local date and time (i.e. not UTC) to the standard output in a format like: '1996-10-15 20:17:25.123 (+0800) +4.567 +/- 0.089 [host] IP sN' where the '(+0800)' means that to get to UTC from the reported local time one must add 8 hours and 0 minutes,

彳亍。

+8000 是说你看到的时间再加上 8 个小时是 UTC (实际上是 UTC-8 的西八区)

东八区当然显示-0800 了

做个实验,带上其他 TZ 执行 sntp:

$ TZ=UTC sntp -c 192.168.0.10
sntp 4.2.8p12@1.3728-o (1)
Can't open KOD db file /var/lib/sntp/kod for writing: Permission denied
2025-02-28 08:33:22.297831 (+0000) +0.0 +/- 0.011989 192.168.0.10 s1 no-leap

这就对了嘛

1703 次点击
所在节点    Linux
2 条回复
Belmode
191 天前
你认真的吗
phpfpm
191 天前
@Belmode 哪里不认真了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1114915

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX