iamkun / iamkun/dayjs

Setting the timezone changes date's unix time

Open
#2,939 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

It appears that my local time zone's DST affects absolute time of the Dayjs object.

```
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc);
dayjs.extend(timezone);

const a = dayjs('2025-10-26T04:00:00.000Z');
const b = dayjs('2025-10-26T04:00:00.000Z').tz('America/New_York');

// getting `false` to all of these comparisons, but I expect them all to be `true`.
console.log(a.valueOf() === b.valueOf());
console.log(a.unix() === b.unix());
console.log(a.toISOString() === b.toISOString());
```

**Information**
- Day.js Version: 1.11.18
- Browser: Chrome 141.0.7390.55 (Official Build) (arm64)
- Time zone: UTC +2 CEST (Europe/Warsaw)

Contributor guide

Open the contributing guide

Research direction

Start by running the provided reproduction with the utc and timezone plugin entry points. Inspect how .tz('America/New_York') affects valueOf(), unix(), and toISOString() around the DST transition. Done means all three comparisons preserve the same absolute instant while retaining the converted display timezone.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.