Skip to content

Instantly share code, notes, and snippets.

@catdad
Created January 17, 2018 15:53
Show Gist options
  • Save catdad/1193bcc3e4f6fc65142d431a8bfe910f to your computer and use it in GitHub Desktop.
Save catdad/1193bcc3e4f6fc65142d431a8bfe910f to your computer and use it in GitHub Desktop.
function excelDateToJsDate(excelDate) {
// this code was originally written in https://gist.github.com/christopherscott/2782634
return new Date(
(excelDate - (25567 + 1)) * 86400 * 1000
);
}
function jsDateToExcelDate(date) {
// just working backwards from the code above
return (date.getTime() / (86400 * 1000)) + (25567 + 1);
}
function isoStringToExcelDate(isoString) {
return jsDateToExcelDate(new Date(isoString));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment