In den meisten neueren Browsern Sie .toISOString()
Methode, aber in IE8 oder älter sind, können Sie die folgenden Befehle verwenden (von json2.js von Douglas Crockford genommen):
// Override only if native toISOString is not defined
if (!Date.prototype.toISOString) {
// Here we rely on JSON serialization for dates because it matches
// the ISO standard. However, we check if JSON serializer is present
// on a page and define our own .toJSON method only if necessary
if (!Date.prototype.toJSON) {
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
}
Date.prototype.toISOString = Date.prototype.toJSON;
}
Jetzt können Sie sicher rufen `.toISOString (Methode).
Versuchen Sie, die Zeitzoneninformationen nicht zu löschen. Siehe http://stackoverflow.com/a/15302113/277267 –