JS date () Day function Browser compatibility problem solving method

Source: Internet
Author: User

The General direct new Date () is not a compatibility issue, and the new date (datetimeformatstring) often has browser compatibility issues, why some format browsers in datetimeformatstring are incompatible.

1. No reference

// no reference all browsers are compatible var New Date ();

2. Date parameters

// Date parameter Format 1 var New Date ("2017-09-12");

A. IE

> ie9-(Incompatible)

> ie9+ (compatible, including IE9)

B. Firefox (compatible)

C. Google (compatible)

// Date parameter Format 2 All browsers are compatible var New Date ("2017/09/12");

3. Date and Time parameters

// Date Time parameter Format 3 var New Date ("2017-09-12t13:42:00");

// Date Time parameter format 1 var New Date ("2017-09-12 13:41:00");

A. IE (incompatible, no matter which version)

B. Firefox (not compatible)

C. Google (compatible)

// Date Time parameter format 2 All browsers are compatible var New Date ("2017/09/12 13:42:00");

A. IE

> ie9-(Incompatible)

> ie9+ (Compatible)

> IE9 (Semi-compatible 8-hour time difference)

B. Firefox (compatible)

C. Google (half-compatible 8-hour time difference)

// Date Time parameter format 4 var New Date ("2017/09/12t13:42:00");

A. IE (half-compatible 1-hour time difference)

B. Firefox (not compatible)

C. Google (not compatible)

Attention:

In all, the formats supported by all major browsers are: var dateTime = new Date ("2017/09/12 13:42:00");

So the solution is to convert datetimeformatstring to YYYY/MM/DD HH:MM:SS formatted string

JS date () Day function Browser compatibility problem solving method

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.