From bf8e099b9c8b3c60d60b3712b4fc97b052c39887 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:23 +0200 Subject: convert content to md --- .../reference/global_objects/date/tojson/index.md | 84 +++++++++------------- 1 file changed, 32 insertions(+), 52 deletions(-) (limited to 'files/fr/web/javascript/reference/global_objects/date/tojson') diff --git a/files/fr/web/javascript/reference/global_objects/date/tojson/index.md b/files/fr/web/javascript/reference/global_objects/date/tojson/index.md index c05c5d8d13..7909061c35 100644 --- a/files/fr/web/javascript/reference/global_objects/date/tojson/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/tojson/index.md @@ -10,69 +10,49 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/Date/toJSON original_slug: Web/JavaScript/Reference/Objets_globaux/Date/toJSON --- -
{{JSRef}}
+{{JSRef}} -

La méthode toJSON() renvoie une chaîne représentant l'objet {{jsxref("Date")}} sous forme {{Glossary("JSON")}}

+La méthode **`toJSON()`** renvoie une chaîne représentant l'objet {{jsxref("Date")}} sous forme {{Glossary("JSON")}} -
{{EmbedInteractiveExample("pages/js/date-tojson.html")}}
+{{EmbedInteractiveExample("pages/js/date-tojson.html")}} -

Syntaxe

+## Syntaxe -
dateObj.toJSON()
+ dateObj.toJSON() -

Valeur de retour

+### Valeur de retour -

Une chaîne de caractères représentant la date indiquée.

+Une chaîne de caractères représentant la date indiquée. -

Description

+## Description -

Les instances de {{jsxref("Date")}} identifient un instant précis dans le temps. Appeler toJSON() renvoie une chaîne de caractères formatée en JSON (en utilisant {{jsxref("Date.prototype.toISOString", "toISOString()")}}), représentant la valeur de l'objet Date. Cette méthode est généralement utilisée, par défaut, pour sérialiser les objets Date lors d'une sérialisation au format JSON.

+Les instances de {{jsxref("Date")}} identifient un instant précis dans le temps. Appeler `toJSON()` renvoie une chaîne de caractères formatée en JSON (en utilisant {{jsxref("Date.prototype.toISOString", "toISOString()")}}), représentant la valeur de l'objet `Date`. Cette méthode est généralement utilisée, par défaut, pour sérialiser les objets `Date` lors d'une sérialisation au format JSON. -

Exemple

+## Exemple -

Utiliser toJSON()

+### Utiliser `toJSON()` -
var jsonDate = (new Date()).toJSON();
+```js
+var jsonDate = (new Date()).toJSON();
 var retourVersDate = new Date(jsonDate);
 
 console.log(jsonDate); //2015-10-26T07:46:36.611Z
-
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES5.1', '#sec-15.9.5.44', 'Date.prototype.toJSON')}}{{Spec2('ES5.1')}}Définition initiale. Implémentée avec 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')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - +``` + +## Spécifications + +| Spécification | État | Commentaires | +| -------------------------------------------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------------- | +| {{SpecName('ES5.1', '#sec-15.9.5.44', 'Date.prototype.toJSON')}} | {{Spec2('ES5.1')}} | Définition initiale. Implémentée avec 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')}} |   | + +## Compatibilité des navigateurs + +{{Compat("javascript.builtins.Date.toJSON")}} + +## Voir aussi + +- {{jsxref("Date.prototype.toLocaleDateString()")}} +- {{jsxref("Date.prototype.toTimeString()")}} +- {{jsxref("Date.prototype.toUTCString()")}} -- cgit v1.2.3-54-g00ecf