--- title: Date.prototype.toJSON() slug: Web/JavaScript/Reference/Global_Objects/Date/toJSON translation_of: Web/JavaScript/Reference/Global_Objects/Date/toJSON original_slug: Web/JavaScript/Referencje/Obiekty/Date/toJSON ---
dateObj.toJSON()
toJSON() zwraca ciąg znaków (using {{jsxref("Date.prototype.toISOString()", "toISOString()")}}) reprezentujący wartość obiektu {{jsxref("Date")}}.
toJSON()var jsonDate = (new Date()).toJSON(); var backToDate = new Date(jsonDate); console.log(jsonDate); //2015-10-26T07:46:36.611Z
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('ES5.1', '#sec-15.9.5.44', 'Date.prototype.toJSON')}} | {{Spec2('ES5.1')}} | Początkowa definicja zaimplementowana w JavaScript 1.8.5. |
| {{SpecName('ES6', '#sec-date.prototype.tojson', 'Date.prototype.toJSON')}} | {{Spec2('ES6')}} | |
| {{SpecName('ESDraft', '#sec-date.prototype.tojson', 'Date.prototype.toJSON')}} | {{Spec2('ESDraft')}} |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
{{Compat("javascript.builtins.Date.toJSON")}}