Date.prototype.getHours()
Resum
El mètode getHours() retorna l'hora per a la data especificada, en temps local.
Sintaxi
dateObj.getHours()Paràmetres
Cap.
Retorna
El valor retornat per getHours() és un nombre sencer entre 0 i 23.
Exemples
Exemple: Utilitzar getHours()
La segona sentència que trobareu a continuació assigna el valor 23 a la variable hora, basant-se en l'objecte Date nadal95.
var nadal95 = new Date('December 25, 1995 23:15:30');
var hora = nadal95.getHours();
console.log(hora); // 23
Especificacions
| Especificació | Estat | Comentaris |
|---|---|---|
| ECMAScript 1a Edició. | Standard | Definició inicial. Implementat a JavaScript 1.0. |
| ECMAScript 5.1 (ECMA-262) The definition of 'Date.prototype.getHours' in that specification. |
Standard | |
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Date.prototype.getHours' in that specification. |
Standard |
Compatibilitat amb navegadors
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
| 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) |