Open
Description
Describe the bug
When using input format as array then output format does't take specified timezone.
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(customParseFormat);
dayjs.tz.setDefault('Europe/Moscow');
// Incorrect, output:
// 31.05.2021 21:00
console.log(
dayjs
.tz('01.06.2021 00:00', ['DD.MM.YYYY HH:mm'], 'Europe/Moscow')
.format('DD.MM.YYYY HH:mm'),
);
Expected behavior
When using just a string for input format the timezone takes correctly.
// Correct, output:
// 01.06.2021 00:00
console.log(
dayjs
.tz('01.06.2021 00:00', 'DD.MM.YYYY HH:mm', 'Europe/Moscow')
.format('DD.MM.YYYY HH:mm'),
);
Information
- Day.js Version: v1.10.7
- OS: macOS 12.0.1 (21A559)
- Browser: NodeJS v15.14.0
- Time zone: GMT+03:00
Links
- Doc about format: https://day.js.org/docs/en/parse/string-format
- PR with supports of array for format: https://github.com/iamkun/dayjs/pull/906/files
Metadata
Metadata
Assignees
Labels
No labels