Difference between date. parse in IE and FF _ javascript skills

Source: Internet
Author: User
This method is very common. For example, you can use it to verify whether the input date exists. If it is a non-existent date, the return value will be NaN, in addition, it can be used to compare the order of two dates or calculate the number of days for the difference between the two dates. Date. parse (dateVal)

This method is very common. For example, you can use it to verify whether the input date exists. If it is a non-existent date, the return value will be NaN, in addition, it can be used to compare the order of two dates or calculate the number of days for the difference between the two dates.

Today, I encountered a strange problem when I used it to compare the date sequence. It is about the date format. The parse method requires that the short date can use "/" or "-" as the separator, however, the format must be monthly, daily, or yearly. For example, if the format is "7/6/2008" or "7-6-2008", the problem occurs here. When the format "7-6-2008" is used, it can be parsed normally in IE, but in FireFox, the return value is always NaN. At first, I thought it was a problem with the Code. After checking the code, I found it was the cause of the browser. Later I changed the format to "7/6/2008" and then it could be parsed in IE and FF.

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.