-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
Describe the bug
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
dayjs.extend(utc);
const timezoneOffset = 0;
const startDate = dayjs('2025-01-06', 'YYYY-MM-DD').utcOffset(timezoneOffset, true);
const endDate = dayjs('2025-01-09', 'YYYY-MM-DD').utcOffset(timezoneOffset, true);
let d = startDate;
while (!d.isAfter(endDate)) {
console.log('date', d.toISOString(), d.utcOffset(), d.format('YYYY-MM-DD'));
d = d.add(1, 'day');
}output:
date 2025-01-06T00:00:00.000Z 0 2025-01-06
date 2025-01-07T00:00:00.000Z 0 2025-01-06
date 2025-01-08T00:00:00.000Z 0 2025-01-07
date 2025-01-09T00:00:00.000Z 0 2025-01-08
Expected behavior
date 2025-01-06T00:00:00.000Z 0 2025-01-06
date 2025-01-07T00:00:00.000Z 0 2025-01-07
date 2025-01-08T00:00:00.000Z 0 2025-01-08
date 2025-01-09T00:00:00.000Z 0 2025-01-09
Information
- Day.js Version v1.11.13
- OS: macOS
- Node.js v20.12.0
- Time zone: UTC+8
skyblue and zuyetawarmatik
Metadata
Metadata
Assignees
Labels
No labels