js 日期比较 (输入的是字符串格式)

var arrJHRQ=document.getElementById("txtstarttime").value.split('-'); //转成成数组,分别为年,月,日,下同
                    var arrJHWCSJ=document.getElementById("txtlasttime").value.split('-');
                    var dateJHRQ=new Date(parseInt(arrJHRQ[0]),parseInt(arrJHRQ[1])-1,parseInt(arrJHRQ[2]),0,0,0); //新建日期对象
                    var dateJHWCSJ=new Date(parseInt(arrJHWCSJ[0]),parseInt(arrJHWCSJ[1])-1,parseInt(arrJHWCSJ[2]),0,0,0);
                    if (dateJHRQ.getTime()>dateJHWCSJ.getTime())
                    {
                        alert('截止时间应大于开始时间');
                        return false;
                    }

你可能感兴趣的:(字符串)