There's a pit---JS date format yyyy-mm-dd and YYYY/MM/DD

Source: Internet
Author: User

There is a hole here,---------each of the pits are summed up after a fortune.

When we write scripts, it is common to define a date format that uses both "2015-12-21" and "2015/12/21" data formats, since the picking date format is not good or bad. However, when we use the following statement to convert the date format, please note the following questions.

1, var dtnow=new Date (' 2015-12-21 ');

2, var dtnow=new Date (' 2015/12/21 ');

When we use the Chorme browser, we will find that both methods can be accurately converted to the desired date format. But when we are in the IE browser, the scenario one is wrong. Because IE does not recognize "-" as the format of the date. So the conversion will fail. It is best to use scenario two in the form of a date format.

There's a pit---JS date format yyyy-mm-dd and YYYY/MM/DD

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.