function yearsDiff(d1, d2) {
var date1 = new Date(d1);
var date2 = new Date(d2);
var yearsDiff = date2.getFullYear() - date1.getFullYear();
return yearsDiff;
}
function monthsDiff(d1, d2) {
var date1 = new Date(d1);
var date2 = new Date(d2);
var years = yearsDiff(d1, d2);
var monthsDiff =(years * 12) + (date2.getMonth() - date1.getMonth()) ;
return monthsDiff;
}
No comments:
Post a Comment