84
JavaScript Date getHours() method
The JavaScript date getHours() method returns the hour for the specified date on the basis of local time.
Syntax
The getHours() method is represented by the following syntax:
Return
An integer value between 0 and 23 that represents the hour.
JavaScript Date getHours() method example
Here, we will understand getHours() method through various examples.
Example 1
Let’s see an example to print the value of current hour.
Output:
15
Example 2
Let’s see an example to print the value of hour from the given date.
Output:
20
Next TopicJavaScript Math