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 --- .../global_objects/date/toisostring/index.md | 94 +++++++++------------- 1 file changed, 38 insertions(+), 56 deletions(-) (limited to 'files/fr/web/javascript/reference/global_objects/date/toisostring') diff --git a/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md b/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md index 102c8dfb19..04e1ce306e 100644 --- a/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md +++ b/files/fr/web/javascript/reference/global_objects/date/toisostring/index.md @@ -11,40 +11,42 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/Date/toISOString original_slug: Web/JavaScript/Reference/Objets_globaux/Date/toISOString --- -
{{JSRef}}
+{{JSRef}} -

La méthode toISOString() renvoie une chaîne de caractères au format ISO (ISO 8601 Extended Format), qui peut être décrite de cette façon : YYYY-MM-DDTHH:mm:ss.sssZ (toujours longue de 24 caractères) ou de cette façon ±YYYYYY-MM-DDTHH:mm:ss.sssZ (27 caractères). Le fuseau horaire est toujours UTC, comme l'indique le suffixe « Z » (pour zéro décalage avec UTC).

+La méthode **`toISOString()`** renvoie une chaîne de caractères au format ISO ([ISO 8601 Extended Format](http://en.wikipedia.org/wiki/ISO_8601)), qui peut être décrite de cette façon : **`YYYY-MM-DDTHH:mm:ss.sssZ`** (toujours longue de 24 caractères) ou de cette façon **`±YYYYYY-MM-DDTHH:mm:ss.sssZ`** (27 caractères). Le fuseau horaire est toujours UTC, comme l'indique le suffixe « Z » (pour zéro décalage avec UTC). -
{{EmbedInteractiveExample("pages/js/date-toisostring.html")}}
+{{EmbedInteractiveExample("pages/js/date-toisostring.html")}} -

Syntaxe

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

Valeur de retour

+### Valeur de retour -

Une chaîne de caractères représentant la date indiquée au format ISO 8601 selon le temps universel.

+Une chaîne de caractères représentant la date indiquée au format [ISO 8601](https://fr.wikipedia.org/wiki/ISO_8601) selon le temps universel. -

Exemples

+## Exemples -

Utiliser toISOString()

+### Utiliser `toISOString()` -
var aujourdhui = new Date("05 October 2011 14:48 UTC");
+```js
+var aujourdhui = new Date("05 October 2011 14:48 UTC");
 
 console.log(aujourdhui.toISOString()); // Renvoie "2011-10-05T14:48:00.000Z"
-
+``` -

L'exemple ci-dessus analyse une chaîne de caractères non-standard, qui peut donc être incorrectement intérprété par des navigateurs n'utilisant pas Gecko.

+L'exemple ci-dessus analyse une chaîne de caractères non-standard, qui peut donc être incorrectement intérprété par des navigateurs n'utilisant pas Gecko. -

Prothèse d'émulation (polyfill)

+## Prothèse d'émulation (_polyfill_) -

Cette méthode fut standardisée avec la cinquième édition d'ECMAScript. Afin d'utiliser cette méthode avec les moteurs qui n'en disposent pas nativement, on pourra utiliser ce fragment de code :

+Cette méthode fut standardisée avec la cinquième édition d'ECMAScript. Afin d'utiliser cette méthode avec les moteurs qui n'en disposent pas nativement, on pourra utiliser ce fragment de code : -
if ( !Date.prototype.toISOString ) {
+```js
+if ( !Date.prototype.toISOString ) {
   ( function() {
 
     function pad(number) {
-      if ( number < 10 ) {
+      if ( number < 10 ) {
         return '0' + number;
       }
       return number;
@@ -62,43 +64,23 @@ console.log(aujourdhui.toISOString()); // Renvoie "2011-10-05T14:48:00.000Z"
     };
 
   }() );
-}
- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES5.1', '#sec-15.9.5.43', 'Date.prototype.toISOString')}}{{Spec2('ES5.1')}}Définition initiale. Implémentée avec JavaScript 1.8.
{{SpecName('ES6', '#sec-date.prototype.toisostring', 'Date.prototype.toISOString')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-date.prototype.toisostring', 'Date.prototype.toISOString')}}{{Spec2('ESDraft')}} 
- -

Compatibilité des navigateurs

- -

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

- -

Voir aussi

- - +} +``` + +## Spécifications + +| Spécification | État | Commentaires | +| -------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ----------------------------------------------------- | +| {{SpecName('ES5.1', '#sec-15.9.5.43', 'Date.prototype.toISOString')}} | {{Spec2('ES5.1')}} | Définition initiale. Implémentée avec JavaScript 1.8. | +| {{SpecName('ES6', '#sec-date.prototype.toisostring', 'Date.prototype.toISOString')}} | {{Spec2('ES6')}} |   | +| {{SpecName('ESDraft', '#sec-date.prototype.toisostring', 'Date.prototype.toISOString')}} | {{Spec2('ESDraft')}} |   | + +## Compatibilité des navigateurs + +{{Compat("javascript.builtins.Date.toISOString")}} + +## Voir aussi + +- {{jsxref("Date.prototype.toLocaleDateString()")}} +- {{jsxref("Date.prototype.toTimeString()")}} +- {{jsxref("Date.prototype.toUTCString()")}} -- cgit v1.2.3-54-g00ecf