Date.prototype.getHours()
Метод getHours()
повертає годину вказаної дати згідно з місцевим часом.
Синтаксис
dateObj.getHours()
Повертає
Ціле число між 0 та 23, яке відображає годину наданої дати згідно з місцевим часом.
Приклади
Використання getHours()
Друга інструкція, наведена нижче, присвоює значення 23 змінній hours
на основі значення об'єкта Date
на ім'я Xmas95
.
let Xmas95 = new Date('December 25, 1995 23:15:30');
let hours = Xmas95.getHours();
console.log(hours); // 23
Специфікації
Специфікація |
---|
ECMAScript (ECMA-262) The definition of 'Date.prototype.getHours' in that specification. |
Сумісність з веб-переглядачами
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.