1 function getDays(strDateStart,strDateEnd){ 2 var strSeparator = "-"; //日期分隔符 3 var oDate1; 4 var oDate2; 5 var iDays; 6 oDate1= strDateStart.split(strSeparator); 7 oDate2= strDateEnd.split(strSeparator); 8 var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2]); 9 var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2]); 10 iDays = parseInt(Math.abs(strDateS - strDateE ) / 1000 / 60 / 60 /24)//把相差的毫秒数转换为天数 11 return iDays ; 12 }