get month difference from two dates in javascript code example
Example 1: javascript date difference in months
function monthDiff(d1, d2) {
var months;
months = (d2.getFullYear() - d1.getFullYear()) * 12;
months -= d1.getMonth();
months += d2.getMonth();
return months <= 0 ? 0 : months;
}
Example 2: get month in two digit in javascript date
("0" + (this.getMonth() + 1)).slice(-2)