日期比较循环第二次向前给出NaN

时间:2016-01-12 13:31:22

标签: javascript jquery

我想比较日期,先工作正常,第二次开始(durationTime = difference between dates)投掷NaN,

在这里遇到问题

var durationTime = ((new Date(endDateVal[2],endDateVal[1],endDateVal[0],endDateVal[3],endDateVal[4],endDateVal[5])) -(new Date(startDateVal[2],startDateVal[1],startDateVal[0],startDateVal[3],startDateVal[4],startDateVal[5])) ) / 1000 / 60 / 60;

这是我的代码,请帮助我

var rowlength = $("#totalLostProductGrid tbody tr ").length;

for(var i=1;i<=rowlength;i++){


    var startDateVal = $("#lpostartDate_"+i).val().split(/-|\s|:/);
    var endDateVal= $("#lpoendDate_"+i).val().split(/-|\s|:/);
    var lostProductValue = $("#lostProductionStartToEnd_"+i).val();
    var realEndDateVal = $("#eEndTime").val().split(/-|\s|:/);

    var FLNominalvalue = $("#idNominalPower").text();
    var idEstimatedLostProdVal = $("#idEstimatedLostProd").val();


    var durationTime = ((new Date(endDateVal[2],endDateVal[1],endDateVal[0],endDateVal[3],endDateVal[4],endDateVal[5])) -(new Date(startDateVal[2],startDateVal[1],startDateVal[0],startDateVal[3],startDateVal[4],startDateVal[5])) ) / 1000 / 60 / 60;

    var actualVal = durationTime * lostProductValue;

    alert(actualVal);

    if(actualVal  < FLNominalvalue){
        alert("success");

    }else{
        alert("invalid case");

        }

}

0 个答案:

没有答案