# GMT时区错误？

**URL:** https://meta.discourse.org/t/timezone-bug-with-gmt/226180
**Category:** Support
**Created:** [2022 年5 月 5 日 03:02 UTC](https://meta.discourse.org/t/timezone-bug-with-gmt/226180 "2022-05-05T03:02:37Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [2022 年5 月 5 日 03:02 UTC](https://meta.discourse.org/t/timezone-bug-with-gmt/226180/1 "2022-05-05T03:02:37Z")

</div>

我不确定这是一个错误还是我误解了它的行为。

## 示例 1

**代码：**

```plaintext
[date=2022-05-06 time=01:00:00 timezone="America/Los_Angeles"]

```

（洛杉矶是 GMT-7。）

**结果：**

2022-05-06T08:00:00Z

## 示例 2

**代码：**

```plaintext
[date=2022-05-06 time=01:00:00 timezone="Etc/GMT-7"]

```

**结果：**

洛杉矶是 GMT-7。如果我们说，“活动时间是 GMT-7（洛杉矶时区）下午 1 点”，并且有人像这样在 Discourse 中使用 GMT-7：

 ![image](https://global.discourse-cdn.com/meta/original/4X/0/5/9/05911d5e5fe1344fd2cec41c79f1e6cd0e435018.png)

结果时间是错误的：

2022-05-05T18:00:00Z

要在那里获得洛杉矶时间（GMT-7），您必须像这样输入 GMT+7：

```plaintext
[date=2022-05-06 time=01:00:00 timezone="Etc/GMT+7"]

```

**结果：**

2022-05-06T08:00:00Z

`America/Los_Angeles+7` 应该与 `GMT` 相同，而 `GMT-7` 应该与 `America/Los_Angeles` 相同，不是吗？该小部件还显示 GMT-7 下午 1 点与洛杉矶不同：

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/d/0/cd0016b4b0476b42fe054146f960813fd777ff9e.png)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2022 年5 月 5 日 06:53 UTC](https://meta.discourse.org/t/timezone-bug-with-gmt/226180/2 "2022-05-05T06:53:10Z")

</div>

我认为这个问题以前出现过：

> [@Conflict between timezones in "Insert date / time"](https://meta.discourse.org/t/conflict-between-timezones-in-insert-date-time/208539/2?u=jammydodger):
>
> I’m afraid the technical reason here is pretty confusing - you can read about it at [Moment Timezone | Docs](https://momentjs.com/timezone/docs/#/zone-object/offset/) POSIX compatibility requires that the offsets are inverted. Therefore, Etc/GMT-X will have an offset of +X and Etc/GMT+X will have an offset of -X . This is a result of IANA’s [Time Zone Database](https://github.com/eggert/tz/blob/2017b/etcetera#L36-L42) and not an arbitrary choice by Moment.js. Thus, using locality based identifiers is preferred over fixed-offset identifiers. So, in IANA’s Time Zone database, Europe/Oslo is currently equivalent…

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [2022 年5 月 5 日 18:29 UTC](https://meta.discourse.org/t/timezone-bug-with-gmt/226180/3 "2022-05-05T18:29:30Z")

</div>

谢谢，我发帖前搜索过，但没看到那个讨论。

我认为如果不带 `Etc/` 前缀显示，并且 `GMT-7` 与 `America/Los_Angeles` 相同，对用户来说会更清晰，但我猜这可能会让那些已经在以编程方式处理日期的人感到意外。

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [2022 年5 月 5 日 19:21 UTC](https://meta.discourse.org/t/timezone-bug-with-gmt/226180/4 "2022-05-05T19:21:01Z")

</div>

很容易忽略 `Los_Angeles` 和 `GMT-7` 并非同一回事。

洛杉矶根据一年中的不同时间，处于太平洋夏令时（PDT，GMT-7）或太平洋标准时（PST，GMT-8），并且不同国家/地区在不同时间进行时钟更改（英国：3 月最后一个星期日和 10 月最后一个星期日，而美国：3 月第二个星期日和 11 月第一个星期日），因此偏移量会有所不同。

这就是为什么日期/时间系统通常会同时显示时区 **和** 偏移量。

---

<div class="post-metadata">

### Author: ![j127](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j127/32/79093_2.png) [@j127](https://meta.discourse.org/u/j127)
#### Post date: [2022 年5 月 5 日 22:00 UTC](https://meta.discourse.org/t/timezone-bug-with-gmt/226180/5 "2022-05-05T22:00:17Z")

</div>

谢谢，我们知道时钟的变化，但那些在时区选择器中找到 GMT-7（或一年中其他时间的 GMT-8）的人可能没有意识到他们输入的日期并非他们想要的。或者当他们看到类似这样的内容时，会觉得不合理，因为洛杉矶目前是 GMT-7：

[![](https://global.discourse-cdn.com/meta/original/4X/c/d/0/cd0016b4b0476b42fe054146f960813fd777ff9e.png) ](https://global.discourse-cdn.com/meta/original/4X/c/d/0/cd0016b4b0476b42fe054146f960813fd777ff9e.png)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2022 年6 月 4 日 22:01 UTC](https://meta.discourse.org/t/timezone-bug-with-gmt/226180/6 "2022-06-04T22:01:12Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
