这个方法在IE6/7/8中不支持,可按下面方式修复下
Home > Web Front-end > JS Tutorial > Fix method for Date not supporting toISOString in IE6-8_javascript skills

Fix method for Date not supporting toISOString in IE6-8_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:50:12
Original
1198 people have browsed it

The Date.prototype.toISOString method was added in ES5 and is not included in the ES3 document. It is as follows:

Fix method for Date not supporting toISOString in IE6-8_javascript skills

This method is not supported in IE6/7/8. You can do it as follows Repair

Copy code The code is as follows:

if (!Date.prototype.toISOString) {
Date.prototype.toISOString = function() {
function pad(n) { return n < 10 ? '0' n : n }
return this.getUTCFulYear() '-'
pad(this.getUTCMonth() 1) '-'
pad(this.getUTCDate()) 'T'
pad(this.getUTCHours()) ':'
pad(this.getUTCMinutes() ) ':'
pad(this.getUTCSeconds()) '.'
pad(this.getUTCMilliseconds()) 'Z';
}
}

Related:
http://msdn.microsoft.com/zh-cn/library/ie/ff925953(v=vs.94).aspx
https://developer.mozilla.org/en-US/ docs/Web/JavaScript/Reference/Global_Objects/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