From 39f2114f9797eb51994966c6bb8ff1814c9a4da8 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 12:36:08 +0100 Subject: unslug fr: move --- .../global_objects/date/getday/index.html | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 files/fr/web/javascript/reference/global_objects/date/getday/index.html (limited to 'files/fr/web/javascript/reference/global_objects/date/getday') diff --git a/files/fr/web/javascript/reference/global_objects/date/getday/index.html b/files/fr/web/javascript/reference/global_objects/date/getday/index.html new file mode 100644 index 0000000000..08457eaade --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/date/getday/index.html @@ -0,0 +1,95 @@ +--- +title: Date.prototype.getDay() +slug: Web/JavaScript/Reference/Objets_globaux/Date/getDay +tags: + - Date + - JavaScript + - Méthode + - Prototype + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDay +--- +
{{JSRef}}
+ +

La méthode getDay() renvoie le jour de la semaine pour la date spécifiée selon l'heure locale (0 correspondant à dimanche). Pour obtenir le jour du mois, on utilisera {{jsxref("Date.prototype.getDate()")}}.

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

Syntaxe

+ +
dateObj.getDay()
+ +

Valeur de retour

+ +

Un entier correspondant au jour de la semaine (0 correspondant à dimanche, 1 à lundi, 2 à mardi et ainsi de suite) de la date indiquée selon l'heure locale.

+ +

Exemples

+ +

Utiliser getDay()

+ +

La seconde instruction ci-dessous assigne la valeur 1 à jourSemaine, selon la valeur de l'objet Date noel95. Le 25 décembre 1995 est un lundi.

+ +
var noel95 = new Date("December 25, 1995 23:15:00");
+var jourSemaine = noel95.getDay();
+
+console.log(jourSemaine); //1
+
+ +
+

Note : Si besoin, on pourra obtenir le nom complet du jour ("lundi" par exemple) en utilisant la méthode {{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}} avec un paramètre options. Ce faisant, il est plus simple d'internationaliser un site ou une application :

+ +
var options = { weekday: 'long'};
+console.log(new Intl.DateTimeFormat('en-US', options).format(Xmas95));
+// Monday
+console.log(new Intl.DateTimeFormat('de-DE', options).format(Xmas95));
+// Montag
+
+
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ESDraft', '#sec-date.prototype.getday', 'Date.prototype.getDay')}}{{Spec2('ESDraft')}} 
{{SpecName('ES6', '#sec-date.prototype.getday', 'Date.prototype.getDay')}}{{Spec2('ES6')}} 
{{SpecName('ES5.1', '#sec-15.9.5.16', 'Date.prototype.getDay')}}{{Spec2('ES5.1')}} 
{{SpecName('ES1')}}{{Spec2('ES1')}}Définition initiale. Implémentée avec JavaScript 1.0.
+ +

Compatibilité des navigateurs

+ + + +

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

+ +

Voir aussi

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