javascript 日期相减

<script language="javascript">
function onClickData(theForm){
var sDate=theForm.pubtime.value;
var eDate=theForm.endtime.value;
var sArr = sDate.split("-");
var eArr = eDate.split("-");
var sRDate = new Date(sArr[0], sArr[1], sArr[2]);
var eRDate = new Date(eArr[0], eArr[1], eArr[2]);
var result = (eRDate-sRDate)/(24*60*60*1000);
if(result<0){
   alert("截至日期必须大于起始日期!");
   theForm.endtime.focus();
   return false;
}
return true;
}
</script>

你可能感兴趣的:(JavaScript)