From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- .../objectes_globals/date/todatestring/index.html | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 files/ca/web/javascript/referencia/objectes_globals/date/todatestring/index.html (limited to 'files/ca/web/javascript/referencia/objectes_globals/date/todatestring/index.html') diff --git a/files/ca/web/javascript/referencia/objectes_globals/date/todatestring/index.html b/files/ca/web/javascript/referencia/objectes_globals/date/todatestring/index.html new file mode 100644 index 0000000000..9548215179 --- /dev/null +++ b/files/ca/web/javascript/referencia/objectes_globals/date/todatestring/index.html @@ -0,0 +1,115 @@ +--- +title: Date.prototype.toDateString() +slug: Web/JavaScript/Referencia/Objectes_globals/Date/toDateString +translation_of: Web/JavaScript/Reference/Global_Objects/Date/toDateString +--- +
{{JSRef}}
+ +

El mètode toDateString() retorna la part de la data d'un objecte {{jsxref("Date")}} en un format entenible per persones en anglés amerià.

+ +

Sintaxi

+ +
objecteData.toDateString()
+ +

Descripció

+ +

Les instàncies de Date representen un punt específic en el temps. Una crida al mètode toString() retornarà la dada en un format entenible per persones, en anglés americà. Al motor SpiderMonkey, aquest format consisteix en la part de la data (dia, mes i any) seguida de la part de l'hora (hores, minuts, segons i zona horària). De vegades és convenient obtenir un string només de la part de l'hora; aquesta és la raó de ser del mètode toDateString().

+ +

El mètode toDateString() resulta especialment útil perquè els motors que compleixen amb el standard ECMA-262 poden retornar resultats diferents al string obtingut mitjançant el mètode toString() en objectes Date, ja que el format depèn totalment de la implementació; això implica que partir el string per a obtenir només la part de temps pot no produïr un resultat consistent en tots els motors.

+ +

Exemples

+ +

Ús bàsic de toDateString()

+ +
var d = new Date(1993, 6, 28, 14, 39, 7);
+
+console.log(d.toString());     // imprimeix Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
+console.log(d.toDateString()); // imprimeix Wed Jul 28 1993
+
+ +

Especificacions

+ + + + + + + + + + + + + + + + + + + + + + + + +
EspecificacióEstatComentaris
{{SpecName('ES3')}}{{Spec2('ES3')}}Definició inicial.
{{SpecName('ES5.1', '#sec-15.9.5.3', 'Date.prototype.toDateString')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-date.prototype.todatestring', 'Date.prototype.toDateString')}}{{Spec2('ES6')}} 
+ +

Compatibilitat amb navegadors

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

Vegeu també

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