Javatpoint Logo
Javatpoint Logo

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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA