I tried to create a small calendar in JavaScript. My date is normal in Firefox and Chrome, but the date function in IE returns NAN.
function Buildweek (datetext) { var headerdates= '; var New Date (datetext); for (var d=0;d<7;d++) { + = ' <th> ' + newdate + ' </th> '; Newdate.setdate (Newdate.getdate ()+1); } JQuery (' div#headerdates '). html (' <table><tr> ' +headerdates+ ' </tr></table> ');}
var // returned from MySQL timestamp/datetime field var a=datestr.split (""); var d=a[0].split ("-"); var t=a[1].split (":"); var New Date (D[0], (d[1]-1), d[2],t[0],t[1],t[2]);
The above method returns Nan on the date of IE
New Date () with many parameters is not supported under IE
Only support this
NewDate (' 11/08/2010 '). GetTime ()-NewDate (' 11/07/2010 '). GetTime ();//90000000NewDate (' 11/07/2010 '). GetTime ()-NewDate (' 11/06/2010 '). GetTime ();//86400000We should use "newdate ()", it takes the input as GMT time:functionnewdate (str) {str=str.split ('-'); varDate=NewDate (); Date.setutcfullyear (str[0], str[1]-1, str[2]); Date.setutchours (0, 0, 0, 0); returndate; }newdate (' 2010-11-07 '). toGMTString (); Newdate (' 2010-11-08 '). togmtstring ();
Date function returns Nan,firefox and chrome in IE normal