excel date to javascript date
// function to convert excel date to normal js date
excelDateToJSDate(excelDate) {
var date = new Date(Math.round((excelDate - (25567 + 1)) * 86400 * 1000));
var converted_date = date.toISOString().split('T')[0];
return converted_date;
}
4.2
5
function ExcelDateToJSDate(serial) {
var utc_days = Math.floor(serial - 25569);
var utc_value = utc_days * 86400;
var date_info = new Date(utc_value * 1000);
var fractional_day = serial - Math.floor(serial) + 0.0000001;
var total_seconds = Math.floor(86400 * fractional_day);
var seconds = total_seconds % 60;
total_seconds -= seconds;
var hours = Math.floor(total_seconds / (60 * 60));
var minutes = Math.floor(total_seconds / 60) % 60;
return new Date(date_info.getFullYear(), date_info.getMonth(), date_info.getDate(), hours, minutes, seconds);
}
Thank you!
5
0
4.5
2
/use excel-date-to-js
//Description
//Converts Excel date in integer format into JS date.
//Dates are stored as numbers in Excel
//and count the number of days since January 0, 1900 (1900 standard, for mac it is 1904, which means January 0, 1904 is the start date).
//Times are handled internally as numbers between 0 and 1.
//Install
//npm install -s excel-date-to-js
//Usage
const { getJsDateFromExcel } = require("excel-date-to-js");
getJsDateFromExcel("42510");
// 2016-05-20T00:00:00.000Z
Thank you!
2
0
3.89
9
var record_date = Date.parse(item.record_date_string)
var days = Math.round((record_date - new Date(1899, 11, 30)) / 8.64e7);
item.record_date = parseInt((days).toFixed(10));
return item;
Thank you!
9
0
Are there any code examples left?
New code examples in category Javascript
-
Javascript 2023-04-21 22:52:36
-
Javascript 2022-03-27 22:25:20 javascript download string as file
-
Javascript 2022-03-27 21:40:22 sort numbers in array javascript
-
Javascript 2022-03-27 21:20:04 compare two arrays and return the difference javascript
-
Javascript 2022-03-27 21:15:02 javascript regex french phone number
-
Javascript 2022-03-27 21:05:03 cypress custom error message
-
Javascript 2022-03-27 21:00:05 create element javascript with id
-
Javascript 2022-03-27 20:40:57 feather icons react
-
Javascript 2022-03-27 20:20:01 how to make graphql request in axios
-
Javascript 2022-03-27 20:15:07 bootstrap validator password and confirm password