From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- .../global_objects/date/tojson/index.html | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 files/uk/web/javascript/reference/global_objects/date/tojson/index.html (limited to 'files/uk/web/javascript/reference/global_objects/date/tojson') diff --git a/files/uk/web/javascript/reference/global_objects/date/tojson/index.html b/files/uk/web/javascript/reference/global_objects/date/tojson/index.html new file mode 100644 index 0000000000..6e03a8664e --- /dev/null +++ b/files/uk/web/javascript/reference/global_objects/date/tojson/index.html @@ -0,0 +1,69 @@ +--- +title: Date.prototype.toJSON() +slug: Web/JavaScript/Reference/Global_Objects/Date/toJSON +tags: + - Date + - JavaScript + - Method + - Prototype + - Дата + - Довідка +translation_of: Web/JavaScript/Reference/Global_Objects/Date/toJSON +--- +
{{JSRef}}
+ +

Метод toJSON() подає об'єкт {{jsxref("Date")}} у вигляді рядка.

+ +

{{EmbedInteractiveExample("pages/js/date-tojson.html")}}

+ + + +

Синтаксис

+ +
dateObj.toJSON()
+ +

Вертає

+ +

Рядок, що містить текстовий запис зазначеної дати.

+ +

Опис

+ +

Кожний об'єкт {{jsxref("Date")}} позначає певну мить у часі. Виклик toJSON() вертає рядок (за допомогою {{jsxref("Date.prototype.toISOString()", "toISOString()")}}), що являє собою текстовий запис дати, яку позначає об'єкт {{jsxref("Date")}}. Зазвичай цей метод вживається для перетворення об'єктів на текст упродовж серіалізації у {{Glossary("JSON")}}.

+ +

Приклади

+ +

Використання toJSON()

+ +
var jsonDate = (new Date()).toJSON();
+var backToDate = new Date(jsonDate);
+
+console.log(jsonDate); //2015-10-26T07:46:36.611Z
+ +

Специфікації

+ + + + + + + + + + +
Специфікація
{{SpecName('ESDraft', '#sec-date.prototype.tojson', 'Date.prototype.toJSON')}}
+ +

Підтримка веб-переглядачами

+ + + +

{{Compat("javascript.builtins.Date.toJSON")}}

+ +

Див. також

+ + -- cgit v1.2.3-54-g00ecf