JavaScript getHours () method
Examples
According to local time hour time field:
var d = new Date();
var n = d.getHours();
var n = d.getHours();
n output:
try it"
Definition and Usage
getHours () method returns the hours of field time.
Browser Support
All major browsers support getHours () method.
grammar
Date.getHours()
return value
类型 | 描述 |
---|---|
Number | 返回值是 0 (午夜) 到 23 (晚上 11 点)之间的一个整数。 |
technical details
JavaScript version: | 1.0 |
---|
More examples
Examples
Returns the specified time hours fields:
var d = new Date("July 21, 1983 01:15:00");
var n = d.getHours();
var n = d.getHours();
n output:
1
try it"
Displays the current time
How getHours (), getMinutes () and getSeconds () to display the current time.