diff options
author | julieng <julien.gattelier@gmail.com> | 2021-08-03 08:03:23 +0200 |
---|---|---|
committer | SphinxKnight <SphinxKnight@users.noreply.github.com> | 2021-09-03 08:08:25 +0200 |
commit | bf8e099b9c8b3c60d60b3712b4fc97b052c39887 (patch) | |
tree | c101746d082c9581c94f5937519c7d0e2f4af8cb /files/fr/web/javascript/reference/global_objects/date/tojson | |
parent | 844f5103992238c0c23203286dad16a466e89c97 (diff) | |
download | translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.tar.gz translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.tar.bz2 translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.zip |
convert content to md
Diffstat (limited to 'files/fr/web/javascript/reference/global_objects/date/tojson')
-rw-r--r-- | files/fr/web/javascript/reference/global_objects/date/tojson/index.md | 84 |
1 files changed, 32 insertions, 52 deletions
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 --- -<div>{{JSRef}}</div> +{{JSRef}} -<p>La méthode <code><strong>toJSON()</strong></code> renvoie une chaîne représentant l'objet {{jsxref("Date")}} sous forme {{Glossary("JSON")}}</p> +La méthode **`toJSON()`** renvoie une chaîne représentant l'objet {{jsxref("Date")}} sous forme {{Glossary("JSON")}} -<div>{{EmbedInteractiveExample("pages/js/date-tojson.html")}}</div> +{{EmbedInteractiveExample("pages/js/date-tojson.html")}} -<h2 id="Syntaxe">Syntaxe</h2> +## Syntaxe -<pre class="syntaxbox"><var>dateObj</var>.toJSON()</pre> + dateObj.toJSON() -<h3 id="Valeur_de_retour">Valeur de retour</h3> +### Valeur de retour -<p>Une chaîne de caractères représentant la date indiquée.</p> +Une chaîne de caractères représentant la date indiquée. -<h2 id="Description">Description</h2> +## Description -<p>Les instances de {{jsxref("Date")}} identifient un instant précis dans le temps. Appeler <code>toJSON()</code> 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 <code>Date</code>. Cette méthode est généralement utilisée, par défaut, pour sérialiser les objets <code>Date</code> lors d'une sérialisation au format JSON.</p> +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. -<h2 id="Exemple">Exemple</h2> +## Exemple -<h3 id="Utiliser_toJSON()">Utiliser <code>toJSON()</code></h3> +### Utiliser `toJSON()` -<pre class="brush:js">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 -</pre> - -<h2 id="Spécifications">Spécifications</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Spécification</th> - <th scope="col">État</th> - <th scope="col">Commentaires</th> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-15.9.5.44', 'Date.prototype.toJSON')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td>Définition initiale. Implémentée avec JavaScript 1.8.5.</td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-date.prototype.tojson', 'Date.prototype.toJSON')}}</td> - <td>{{Spec2('ES6')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-date.prototype.tojson', 'Date.prototype.toJSON')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </td> - </tr> - </tbody> -</table> - -<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> - -<p>{{Compat("javascript.builtins.Date.toJSON")}}</p> - -<h2 id="Voir_aussi">Voir aussi</h2> - -<ul> - <li>{{jsxref("Date.prototype.toLocaleDateString()")}}</li> - <li>{{jsxref("Date.prototype.toTimeString()")}}</li> - <li>{{jsxref("Date.prototype.toUTCString()")}}</li> -</ul> +``` + +## 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()")}} |