Different `utcOffset()` result in firefox and chrome
Author: heroboyCreated May 6, 2020Updated Sep 2, 2026
LabelsFractional-Hour UTC OffsetKnown Issue
Describe the bug
moment(new Date(1899, 11, 30, 0, 0, 0)).utcOffset()'s result is different in chrome and firefox
To Reproduce Steps to reproduce the behavior:
- Open browser console and run above js.
Expected behavior The result should be correct and same in all environment
Desktop (please complete the following information):
- OS: windows 10
- Browser: firefox, chrome
- Version: latest realse
Moment-specific environment for js:
d = new Date(1899, 11, 30, 0, 0, 0);
[moment(d).utcOffset(),d.toString(),d.toLocaleString(),d.getTimezoneOffset(),Intl.DateTimeFormat().resolvedOptions()];
[new Date().toString(),new Date().toLocaleString(),new Date().toISOString()];
result in chrome:
[
485,
"Sat Dec 30 1899 00:00:00 GMT+0805 (中国标准时间)",
"1899/12/30 上午12:00:00",
-485,
{
"locale": "zh-CN",
"calendar": "gregory",
"numberingSystem": "latn",
"timeZone": "Asia/Shanghai",
"year": "numeric",
"month": "numeric",
"day": "numeric"
}
]
["Wed May 06 2020 17:44:46 GMT+0800 (中国标准时间)", "2020/5/6 下午5:44:46", "2020-05-06T09:44:46.709Z"]
result in firefox:
[
486,
"Sat Dec 30 1899 00:00:00 GMT+0805 (中国标准时间)",
"1899/12/30 上午12:00:00",
-485.71666666666664,
{
"locale": "zh-Hans-CN",
"calendar": "gregory",
"numberingSystem": "latn",
"timeZone": "Asia/Shanghai",
"year": "numeric",
"month": "numeric",
"day": "numeric"
}
]
[ "Wed May 06 2020 17:44:03 GMT+0800 (中国标准时间)", "2020/5/6 下午5:44:03", "2020-05-06T09:44:03.036Z" ]
Additional context The original issue is here: https://github.com/SheetJS/sheetjs/issues/1918 But I think you are professionals of datetime, and momentjs actually has the same issue, so I post issue here.
Source: moment/moment