1

All the date, related Values are shown as NaN, although the same JS codes, works fine in chrome, giving me the correct values, HEre's a section, of those date codes.

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;
r_a_k
  • 111
  • 2
  • 8
  • 1
    Please show the exact value of `data.list[s].dt_txt`. Probably `date === Invalid Date` in non-working browsers. – Teemu Oct 06 '14 at 17:46
  • Although it won't solve your problem of the date text you are using not being parseable in most browsers, *please* consider refactoring your code and formatting it neatly. For formatting, there are online utilities, e.g. [javascriptformat.com](http://www.javascriptformat.com/). For refactoring, you can have *one* function which returns an object with, say, `.date` and `.time` properties; to do that see [Return multiple values in JavaScript?](http://stackoverflow.com/questions/2917175/return-multiple-values-in-javascript). – Andrew Morton Oct 06 '14 at 18:54
  • data.list[s].dt_txt parses JSON and it gets values in format, 2014-10-07 00:00:00 – r_a_k Oct 07 '14 at 01:53
  • Like stated above: [`Invalid Date`](http://jsfiddle.net/c3ny8nq3/) (should be `'2014-10-07T00:00:00'`). Can you please tell, what actually has prevented you to do some basic debugging? – Teemu Oct 07 '14 at 04:10
  • Heay Thnku So So much, I fixed it. When tried by inserting a 'T' replacing the between the date string, 2014-10-07T00:00:00 it worked as intended. I was on course of developing a web-app, http://cloudseek.heroku.com and thanking u for making me out of the stuck :D – r_a_k Oct 07 '14 at 11:41

0 Answers0