Date.prototype.getHours()
Il metodo getHours()
restituisce l'ora per la data specificata in accordo con l'ora locale.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Sintassi
dateObj.getHours()
Valore di ritorno
Un numero di tipo integer, tra 0 e 23, rappresentante l'ora per la data fornita in accordo con l'ora locale.
Esempi
Utilizzando getHours()
La seconda dichiarazione qui sotto assegna il valore 23 alla variabile hours
, basata sul valore dell'oggetto Date
Xmas95
.
var Xmas95 = new Date('December 25, 1995 23:15:30');
var hours = Xmas95.getHours();
console.log(hours); // 23
Specificazioni
Specification | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Definizione iniziale. Implementata in 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 | |
ECMAScript (ECMA-262) The definition of 'Date.prototype.getHours' in that specification. |
Living Standard |
Browser compatibility
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.