Here is my implementation:
function daysBetween(one, another) {
return Math.round(Math.abs((+one) - (+another))/8.64e7);
}
+<date>
does the type coercion to the integer representation and has the same effect as <date>.getTime()
and 8.64e7
is the number of milliseconds in a day.