JavaScript getUTCHours()Method

Date 对象参考手册JavaScript Date Object

Example

Return the hour of the time according to UTC:

var d = new Date();
var n = d.getUTCHours();

nOutput:


Try it Yourself »

Definition and Usage

The getUTCHours() method returns the hour of the time according to UTC.

Coordinated Universal Time (UTC) is a time measurement system based on the atomic second, which is as close as possible to Universal Time in terms of moments.

Tip:Coordinated Universal Time, also known as Universal Time Coordinated, World Standard Time, International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).

Note:UTC time is the same as GMT (Greenwich) time.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the getUTCHours() method.


Syntax

Date.getUTCHours()

Return Value

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

Technical Details

JavaScript Version: 1.3


More Examples

Example

Here, we will extract the UTC hour from a specific date and time:

var d=new Date("July 21, 1983 01:15:00");
var n=d.getUTCHours();

nOutput


Try it Yourself »

实例s

Display the current UTC time
How to use getUTCHours(), getUTCMinutes() and getUTCSeconds() to display the current UTC time.


Date 对象参考手册JavaScript Date Object

Other Extensions