Dayjs 时区转换错误

问题描述 投票:0回答:1
// DATE = 2024-06-13T23:59:59+05:00
  let dateTime = dayjs(date, format, locale, strict);

  // +05 UTC OFFSET
  dateTime = dateTime.utcOffset(300);

  console.log('1 - ', dateTime.format());
  // 2024-06-13T23:59:59+05:00 | OK

  // -03 UTC OFFSET
  dateTime = dateTime.utcOffset(-180);

  console.log('2 - ', dateTime.format());
  // 2024-06-13T07:59:59-03:00 | WRONG! SHOULD BE 15:59:59-03:00

不知道为什么 dayjs 将 2024-06-13T23:59:59+05:00 转换为 2024-06-13T07:59:59-03:00

timezone dayjs
1个回答
0
投票

这似乎是一个错误,并且已在此处报告: https://github.com/iamkun/dayjs/issues/2427

© www.soinside.com 2019 - 2024. All rights reserved.