JAVASCRIPT:
-
function monthsBetween(thisDate, thatDate) {
-
if (thisDate> thatDate) {
-
return monthsBetween(thatDate, thisDate);
-
}
-
-
var number = 0;
-
if (thatDate.getFullYear()> thisDate.getFullYear()) {
-
number = number + (thatDate.getFullYear() - thisDate.getFullYear() - 1) * 12;
-
} else {
-
return thatDate.getMonth() - thisDate.getMonth();
-
}
-
-
if (thatDate.getMonth()> thisDate.getMonth()) {
-
number = number + 12 + thatDate.getMonth() - thisDate.getMonth();
-
} else {
-
number = number + (12 - thisDate.getMonth()) + thatDate.getMonth();
-
}
-
return number;
-
}
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment