Date function returns Nan,firefox and chrome in IE normal

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.