Date.prototype.toGMTString()
Deprecated
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
El mètode toGMTString()
converteix una data a un string, utilitzant les convencions del Greenwich Mean Time (GMT). El format exacte del valor retornat per toGMTString()
és depenent de la plataforma i el navegador, per norma general hauria de representar la data en una forma entenible per persones.
Nota: toGMTString()
està en desús i no es recomana fer-lo servir més. Es mantè només per a compatibilitat amb codi vell que l'utilitzi; en comptes d'aquest mètode utilitzeu toUTCString()
(en-US).
Sintaxi
objecteData.toGMTString()
Exemples
Exemple senzill
En aquest exemple el mètode toGMTString()
converteix la data a GMT (UTC) utilitzant el desplaçament de zona horaria donat pel sistema operatiu i retorna un valor string que té aproximadament la forma que trobareu a continuació. El format exacte dependrà de la plataforma.
var avui = new Date();
var str = avui.toGMTString(); // en desús! utilitzeu toUTCString()
console.log(str); // Mon, 18 Dec 1995 17:28:35 GMT
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Definició inicial, però ja marcat com a en desús. Implementat a JavaScript 1.0. |
ECMAScript 5.1 (ECMA-262) The definition of 'Date.prototype.toGMTString' in that specification. |
Standard | Definit a l'annex de compatibilitat (informatiu). |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Date.prototype.toGMTString' in that specification. |
Standard | Definit a l'annex per a característiques adicionals per a navegadors web (normatiu). |
Compatibilitat amb navegadors
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport bàsic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Característica | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport bàsic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |