English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
getHours()Returns the hour of the specified date object based on local time (0-23).
getHours()The returned value is from 0 to23integer between.
date.getHours()
var d = new Date(); d.getHours();Test and see‹/›
All browsers fully support the getHours() method:
Method | |||||
getHours() | is | is | is | is | is |
Return Value: | 0 to23are integers representing hours between |
---|---|
JavaScript Version: | ECMAScript 1 |
Return the hour of a specific date and time:
var d = new Date(#39;August 20, 1999 23:15:30'); d.getHours();Test and see‹/›
Use the getHours(), getMinutes(), and getSeconds() methods to display the time:
setInterval(function () { var date = new Date(); var x = document.getElementById('result'); x.innerHTML = date.getHours() + " + date.getMinutes() + " + date.getSeconds(); }, 1000);Test and see‹/›