Here you can find the source of toJSON()
/** section: Language//from w w w . jav a 2 s .c o m * class Date * * Extensions to the built-in `Date` object. **/ /** * Date#toJSON() -> String * * Produces a string representation of the date in ISO 8601 format. * The time zone is always UTC, as denoted by the suffix "Z". * * <h5>Example</h5> * * var d = new Date(1969, 11, 31, 19); * d.getTimezoneOffset(); * //-> -180 (time offest is given in minutes.) * d.toJSON(); * //-> '"1969-12-31T16:00:00Z"' **/ Date.prototype.toJSON = function() { return '"' + this.getUTCFullYear() + '-' + (this.getUTCMonth() + 1).toPaddedString(2) + '-' + this.getUTCDate().toPaddedString(2) + 'T' + this.getUTCHours().toPaddedString(2) + ':' + this.getUTCMinutes().toPaddedString(2) + ':' + this.getUTCSeconds().toPaddedString(2) + 'Z"'; };
Date.prototype.toJSON = function() { return '"' + this.getUTCFullYear() + '-' + (this.getUTCMonth() + 1).toPaddedString(2) + '-' + this.getUTCDate().toPaddedString(2) + 'T' + this.getUTCHours().toPaddedString(2) + ':' + this.getUTCMinutes().toPaddedString(2) + ':' + this.getUTCSeconds().toPaddedString(2) + 'Z"'; };
Date.prototype.toJSON = function() { return '"' + this.getUTCFullYear() + '-' + (this.getUTCMonth() + 1).toPaddedString(2) + '-' + this.getUTCDate().toPaddedString(2) + 'T' + this.getUTCHours().toPaddedString(2) + ':' + this.getUTCMinutes().toPaddedString(2) + ':' + this.getUTCSeconds().toPaddedString(2) + 'Z"'; };
'use strict'; function pad(n) { return n < 10 ? '0' + n : n; Date.prototype.toJSON = function() { var s = this.getFullYear() + '-' + pad(this.getMonth() + 1) + '-' + pad(this.getDate()) + 'T' + pad(this.getHours()) + ':' + pad(this.getMinutes()) + ':' + pad(this.getSeconds()); var offset = this.getTimezoneOffset(); if (offset === 0) { ...
String.format = function () { var s = arguments[0]; for (var i = 0; i < arguments.length - 1; i++) { var reg = new RegExp("\\{" + i + "\\}", "gm"); s = s.replace(reg, arguments[i + 1]); return s; Date.prototype.toJSON = function () { return String.format("/Date({0})/", this.getTime() - this.getTimezoneOffset() * 60000) } ...
Date.prototype.toJSON = function() { return this.toISOString(); };
Date.prototype.toJSON = function() { return this.getUTCFullYear() + '/' + f(this.getUTCMonth() + 1) + '/' + f(this.getUTCDate()) + ' ' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + ' +0000'; };
"use strict"; Date.prototype.toJSON = function () { var year = this.getUTCFullYear(), month = this.getUTCMonth() + 1, date = this.getUTCDate(), hour = this.getUTCHours(), minute = this.getUTCMinutes(), second = this.getUTCSeconds(); return ( ...
Date.prototype.toJSON = function (key) { function f(n) { return n < 10 ? '0' + n : n; return this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + ...
Date.prototype.toJSON = function(key) { function f(n) { return n < 10 ? '0' + n : n; return isFinite(this.valueOf()) ? this.getFullYear() + '-' + f(this.getMonth() + 1) + '-' + f(this.getDate()) + ' ' + f(this.getHours()) + ':' + f(this.getMinutes()) + ':' + f(this.getSeconds()) : null; };