function getMonthBetween(startDate,endDate){ startDate=new Date(startDate.replace(/-/g,'/')); endDate=new Date(endDate.replace(/-/g,'/')); var num=0; var year=endDate.getFullYear()-startDate.getFullYear(); num+=year*12; var month=endDate.getMonth()-startDate.getMonth(); num+=month; var day=endDate.getDate()-startDate.getDate(); if(day>0){ //if(day>15){ num+=1; } num+=1; }else if(day<0){ //if(day<-15){num-=1; } //num-=1; } return num; }