Created
June 21, 2018 09:58
-
-
Save szmeku/f50699ec658876f74c064c4953be5413 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
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment