Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTC, UT, GMT, 时区 和 时间戳 #52

Open
techiall opened this issue Mar 15, 2019 · 0 comments
Open

UTC, UT, GMT, 时区 和 时间戳 #52

techiall opened this issue Mar 15, 2019 · 0 comments

Comments

@techiall
Copy link
Owner

UTC, UT 和 GMT

  • 格林尼治平时(Greenwich Mean Time),简称 GMT

  • 世界时(Universal Time),简称 UT

  • 协调世界时(Coordinated Universal Time),简称 UTC

UTC, UT, GMT 三者出现的先后顺序: GMT -> UT -> UTC,我们可以把 GMT 和 UTC 看作一样的。

GMT 和 UTC 都是用 数来计算的。

时区

  • 全球划分为 24 个时区

  • 时区可以用 UTC 表示,范围为 UTC-12 --- UTC-11 --- UTC-1 --- UTC --- UTC-1 --- UTC+11 --- UTC+12,依次增加

  • 相差多少个时区,就是相差多少个小时

  • 时区可以按 区域/位置 的格式表示,就可以得到一个独有的名称(时区有很多种表示方式)

以 中国时区 为例。

  • China Standard Time (CST), UTC +8、

  • 无夏令时,全年 UTC 偏移量不变

  • 中国的 IANA 时区标识符为 Asia/Shanghai。

时间戳

  • 时间戳(Timestamp)是指字符串或编码信息用于辨识记录下来的时间日期。国际标准为 ISO 8601

  • 时间戳是从 协调世界时(UTC) 1970 年 1 月 1 日 0 时 0 分 0 秒 起至现在的总秒数,不考虑闰秒

  • 时间戳是用无符号整数表示

  • 时间戳 和 UTC 进行转换,UTC 和 时区 进行转换,因此 时间戳 也可以和 UTC 进行转换

  • 有 秒级(10 位), 毫秒级(13 位) 的时间戳,也有纳米级(19 位) 的时间戳,如 Java 就可以处理到纳米级

本地时间是指当前操作系统设定的时区。例如北京时区是东8区,则本地时间:

2015-04-19 12:20:00

实际上就是UTC+8:00时区的时间:

2015-04-19 12:20:00 UTC+8:00

而此刻的格林威治标准时间与北京时间差了8小时,也就是UTC+0:00时区的时间应该是:

2015-04-19 04:20:00 UTC+0:00

原文链接:https://blog.csdn.net/zheng_lan_fang/article/details/79448965

  • 因为时区的关系,由于没设置使用者的时区,所以就会看到在一些系统上会出现时间慢了 8 个小时的现象(以北京时区为例)

  • 不同的编程语言可以通过设置的方式来调整时区

  • 不同的编程语言 格式化 时间的方式也不同(如:yyyy-mm-dd hh:mm:ss),为确保统一,我们可以使用时间戳(mysql,Java,JavaScript 存放时间都用 时间戳,就不会产生写入和读出不一致了。

参考链接

@techiall techiall added the Hexo label Mar 15, 2019
@techiall techiall mentioned this issue May 31, 2019
@techiall techiall removed the Hexo label Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant