inconsistent timezone offset when passing in unix timestamp and iso string
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I am seeing different results when passing in unix timestamps and iso string. `1596265200000` is `2020-08-01` at that timezone.
```
dayjs.tz(1596265200000, 'America/Los_Angeles').format()
"2020-08-01T00:00:00-08:00"
dayjs.tz('2020-08-01', 'America/Los_Angeles').format()
"2020-08-01T00:00:00-07:00"
dayjs('2020-08-01').tz('America/Los_Angeles').format()
"2020-08-01T00:00:00-08:00"
dayjs('2020-08-01').tz('America/Los_Angeles').utcOffset()/60
-8
moment('2020-08-01').tz('America/Los_Angeles').utcOffset()/60
-7
```
**Expected behavior**
should all be `2020-08-01T00:00:00-07:00`, since `America/Los_Angeles` is UTC-07:00 in summer.
**Information**
- Day.js Version: v1.9.6
- OS: Mac
- Browser: chrome 86
- Time zone: GMT-08:00 PST (Pacific Standard Time)]
Contributor guide
Research direction
Reproduce the three dayjs.tz, dayjs(...).tz, and utcOffset() examples from the issue using America/Los_Angeles and the supplied timestamp. Trace the timezone-handling entry point involved in these calls, then verify that the timestamp and ISO-string forms produce the expected summer offset of -07:00, matching the existing Moment.js result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- internationalization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100