Home > Web Front-end > JS Tutorial > body text

The difference between date.parse in IE and FF_javascript skills

WBOY
Release: 2016-05-16 18:22:19
Original
990 people have browsed it

Date.parse(dateVal)

This method is very commonly used. For example, you can use it when verifying whether the input date exists. If it is a non-existent date, the return value will be NaN. In addition, if You can use it to compare the order of two dates, or to calculate the number of days between two dates.

I encountered a strange problem today when I used it to compare dates. It was about the date format. The parse method requires that short dates can use "/" or "-" as the separator, but the month must be used. /day/year format, for example, today is "7/6/2008" or "7-6-2008". The problem arises here. When using the format "7-6-2008", in 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, I found out that it was the browser. Later, I changed the format to "7/6/2008" and it can be parsed normally in IE and FF.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!