Home » JavaScript Date getHours() Method

JavaScript Date getHours() Method

by Online Tutorials Library

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.

Test it Now

Output:

15  

Example 2

Let’s see an example to print the value of hour from the given date.

Test it Now

Output:

20  

Next TopicJavaScript Math

You may also like