Easy Tutorial
❮ Jsref Getutcday Prop Style Tabsize ❯

JavaScript getHours() Method

JavaScript Date Object

Example

Returns the hour field of the time based on local time:

n Output result:


Definition and Usage

The getHours() method returns the hour field of the time.


Browser Support

All major browsers support the getHours() method.


Syntax

Return Value

Type Description
Number The return value is an integer between 0 (midnight) and 23 (11 PM).

Technical Details

| JavaScript Version: | 1.0 | | --- | --- |


More Examples

Example

Returns the hour field of a specified time:

n Output result:

Display Current Time


JavaScript Date Object

❮ Jsref Getutcday Prop Style Tabsize ❯