-
-
Save jdrew1303/0b4f063313ff19fb83d0 to your computer and use it in GitHub Desktop.
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 timeUntil = { | |
inHours: function(d1, d2) { | |
return parseInt((d2.getTime()-d1.getTime())/(24*3600), 10); | |
}, | |
inDays: function(d1, d2) { | |
return parseInt((d2.getTime()-d1.getTime())/(24*3600*1000), 10); | |
}, | |
inWeeks: function(d1, d2) { | |
return parseInt((d2.getTime()-d1.getTime())/(24*3600*1000*7), 10); | |
}, | |
inMonths: function(d1, d2) { | |
return (d2.getMonth()+12*d2.getFullYear())-(d1.getMonth()+12*d1.getFullYear()); | |
}, | |
inYears: function(d1, d2) { | |
return d2.getFullYear()-d1.getFullYear(); | |
} | |
} | |
var endDate = new Date("July, 20, 2012"); | |
var startDate = new Date(); | |
console.log(timeUntil.inDays(startDate,endDate)); | |
console.log(timeUntil.inHours(startDate,endDate)); | |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment