日期:2014-05-16 浏览次数:20353 次
function setRateValidity(){ var beginDate = document.getElementById("crlimit:beginDate").value; var endDate = document.getElementById("crlimit:endDate").value; if(beginDate!=""&&endDate!=""&&endDate>=beginDate&&(endDate-beginDate)<=10000){ var startDate = new Date(beginDate.substr(0,4),beginDate.substr(4,2)-1,beginDate.substr(6,2));//月份是从0开始算的 var startDateUTC = Date.UTC(startDate.getFullYear(),startDate.getMonth(),startDate.getDate()); var end = new Date(endDate.substr(0,4),endDate.substr(4,2)-1,endDate.substr(6,2)); var endDateUTC = Date.UTC(end.getFullYear(),end.getMonth(),end.getDate()); var workmonthnum = 0; for (var i=startDateUTC;i<=endDateUTC ; i=i+86400000 ){ var days = new Date(i); if (days.getDate()==1){ workmonthnum++; } } if(beginDate.substr(6,2)=='01'&&endDate.substr(6,2)=='01'){ workmonthnum = workmonthnum -1; } if(beginDate.substr(0,4)==endDate.substr(0,4)&&beginDate.substr(4,2)==endDate.substr(4,2)){ workmonthnum = 1; } document.getElementById("crlimit:rateValidity").value = workmonthnum; } }