function Computation(sDate1, sDate2){ var aDate, oDate1, oDate2, iDays aDate = sDate1.split("-") oDate1 = new Date(aDate[2] + '-' + aDate[1] + '-' + aDate[0]) aDate = sDate2.split("-") oDate2 = new Date(aDate[2] + '-' + aDate[1] + '-' + aDate[0]) iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24) return iDays }
调用方法
Computation('18-01-2012','19-01-2012')