Inconsistent TZ Behavior Around UTC
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Setup**
```js
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc);
dayjs.extend(timezone);
```
**Describe the bug**
`dayjs('2021-08-14').tz('Etc/GMT').hour(12).unix()` => `1628924400`
`dayjs('2021-08-14').tz('UTC').hour(12).unix()` => `1628924400`
`1628924400` is `GMT: Saturday, August 14, 2021 7:00:00 AM`
**Expected behavior**
`1628942400` is the expected value (`GMT: Saturday, August 14, 2021 12:00:00 PM`)
Time zones around UTC behave as expected:
`dayjs('2021-08-14').tz('Etc/GMT-1').hour(12).unix()` => `1628938800` (`GMT: Saturday, August 14, 2021 11:00:00 AM`)
`dayjs('2021-08-14').tz('Etc/GMT+1').hour(12).unix()` => `1628946000` (`GMT: Saturday, August 14, 2021 1:00:00 PM`)
It seems like something special is happening behind the scenes when the timezone is at UTC vs. other time zones. It's like it uses my local time zone when using `.unix` in the UTC case but not the others.
**Information**
- Day.js Version `v1.10.6`
- OS: macOS
- Node.js `v16.5.0`
- Time zone: US Central (currently UTC−05:00)
Contributor guide
Assessment
This issue has not been assessed yet.