Last active
March 12, 2021 13:53
-
-
Save DavidWells/636e49b3d1835eb4eac77ccfb74c6de7 to your computer and use it in GitHub Desktop.
Get difference between two dates. Number of days between unix timestamps
This file contains 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
var numDaysBetween = function(d1, d2) { | |
var today = d2.getTime() / 1000 | |
console.log('today', today) | |
var diff = Math.abs(d1 - (d2.getTime() / 1000)); | |
console.log('diff', diff) | |
return diff / (60 * 60 * 24); | |
}; | |
var d1 = 1497294888; // June 12, 2017 | |
var d2 = new Date(); // Today | |
numDaysBetween(d1, d2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome!