-
-
Save scottschreckengaust/a37472c550fbcdcbf45b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert Excel dates into JS date objects | |
// | |
// @param excelDate {Number} | |
// @return {Date} | |
function getJsDateFromExcel(excelDate) { | |
// JavaScript dates can be constructed by passing milliseconds | |
// since the Unix epoch (January 1, 1970) example: new Date(12312512312); | |
// 1. Subtract number of days between Dec 30, 1899 and Jan 1, 1970 | |
// 2. Convert to milliseconds. | |
if (isNaN(excelDate)) { | |
return excelDate; | |
} else { | |
return new Date((excelDate - 25569) * 86400 * 1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment