IE和Mozilla中的日期值显示为NaN,但在Chrome中工作正常

时间:2014-10-06 17:33:13

标签: javascript internet-explorer date mozilla nan

所有日期,相关的值都显示为NaN,尽管相同的JS代码在chrome中工作正常,给我正确的值,这是这些日期代码的一部分。

var date = new Date(data.list[s].dt_txt);
        var year = date.getFullYear();var month = date.getMonth()+1; var dat = date.getDate();
        if(month<10){month='0'+month;}if(dat<10){dat='0'+dat;}
        var hour = date.getHours();var minute = date.getMinutes(); var sec = date.getSeconds();
        if(hour<10){hour='0'+hour;}if(minute<10){minute='0'+minute;}if(sec<10){sec='0'+sec}
        var ftime = hour+':'+minute+':'+sec;
        var fdate = year+'-'+month+'-'+dat;
        ///\\
        var date = new Date(data.list[s+1].dt_txt);
        hour = date.getHours();minute = date.getMinutes();sec = date.getSeconds();
        if(hour<10){hour='0'+hour;}if(minute<10){minute='0'+minute;}if(sec<10){sec='0'+sec}
        var ttime = hour+':'+minute+':'+sec;
        c1.innerHTML='+fdate+';
        c2.innerHTML=''+ftime+' to '+ttime+'';
        c3.innerHTML=data.list[s].weather[0].main;

0 个答案:

没有答案