Home > Web Front-end > JS Tutorial > Solution to the problem that IE browser does not support NEW DATE() with parameters in javascript_javascript tips

Solution to the problem that IE browser does not support NEW DATE() with parameters in javascript_javascript tips

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:55:39
Original
1474 people have browsed it
Copy code The code is as follows:

var date1=new Date(dateTimes[z][1]);

The time can be obtained normally under Firefox, but it is NaN under IE7. After struggling for a long time, I gave up on new date and then found a piece of code in a foreigner's forum that could be compatible with the formatted date code of all browsers:
Copy code The code is as follows:

function NewDate(str) {
str = str.split('-');
var date = new Date();
date.setUTCFulYear(str[0], str[1] - 1, str[2]);
date.setUTCHours(0, 0, 0, 0);
return date;
}
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
Latest Issues
Compare JavaScript Date objects
From 1970-01-01 08:00:00
0
0
0
Select rows grouped by date
From 1970-01-01 08:00:00
0
0
0
Hive query: Convert date timestamp to date format
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template