PLAIN TEXT
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;
}