英文:
What is this date format? 44303.02359 . new Date() can't parse it
问题
Google Sheets可以识别44303.02359
的日期格式为4/17/2021,但JavaScript的new Date()
无法识别,它认为这是1969年的日期。请问这个日期的格式是什么?我应该如何在JavaScript中解析它?
英文:
I have a list of dates in the format of 44303.02359
and google sheets is able to determine that it's 4/17/2021 but javascript new Date()
is unable to, it thinks it's in 1969. My google search for "Two number date separated with a period" isn't proving helpful.
What format is this? How can I parse it with javascript?
答案1
得分: 1
这是一个Excel日期的“序列号”
> 默认情况下,1900年1月1日是序列号1,2008年1月1日是序列号39448,因为它距离1900年1月1日已经过去了39,447天。
来源:https://support.microsoft.com/en-us/office/datevalue-function-df8b07d4-7761-4a93-bc33-b7471bbff252
有一个很棒的短转换函数
function ExcelDateToJSDate(date) {
return new Date(Math.round((date - 25569) * 86400 * 1000));
}
来源:https://stackoverflow.com/a/22352911/7549483
英文:
It is an Excel date "serial number"
> By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.
Source: https://support.microsoft.com/en-us/office/datevalue-function-df8b07d4-7761-4a93-bc33-b7471bbff252
There is a great short converter function
function ExcelDateToJSDate(date) {
return new Date(Math.round((date - 25569)*86400*1000));
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论