iamkun / iamkun/dayjs

Why can't all dates return the correct date based on the timezone?

Open
#2,785 3 comments 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

import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';

dayjs.extend(utc);
dayjs.extend(timezone);

dayjs.tz.setDefault('America/New_York');

const time1 = dayjs.tz('2024-12-11T12:37:43.000Z', 'America/Toronto').format('YYYY-MM-DD HH:mm');
console.log(time1);
const time2 = dayjs.tz('2024-12-11T12:37:43.000Z', 'America/New_York').format('YYYY-MM-DD HH:mm');
console.log(time2);
const time3 = dayjs.tz('2024-12-11T12:37:43.000Z', 'Asia/Hong_Kong').format('YYYY-MM-DD HH:mm');
console.log(time3);

export default dayjs;

Result: time1 = 2024-12-11 12:37
time2 = 2024-12-11 12:37
time3 = 2024-12-11 12:37

"dayjs": "^1.11.13"

Why can't all dates return the correct date based on the timezone?

Contributor guide

Open the contributing guide

Research direction

Start by running the provided reproduction with dayjs/plugin/utc and dayjs/plugin/timezone using the three named timezones and the dayjs 1.11.13 dependency. Trace the timezone conversion and formatting behavior, then verify that each timezone produces the expected local date and time.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.