getUTCHours Method (Date) (JavaScript)

Gets the hours value in a Date object using Universal Coordinated Time (UTC).




The required dateObj reference is a Date object.

Return Value

Returns an integer between 0 and 23 indicating the number of hours since midnight. Zero is returned if the time is before 1:00:00 am. If a Date object was created without specifying the time, by default the hour is 0 in UTC time. This time may be non-zero in other time zones.


To get the number of hours elapsed since midnight using local time, use the getHours method.


The following example illustrates the use of the getUTCHours method.

var date = new Date("1/1/2001");  

var date2 = new Date("1/1/2001 11:22:33");  

// Output (in the PST time zone):  
// 15 
// 2  


Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Applies To: Date Object

See Also

getHours Method (Date)
setHours Method (Date)
setUTCHours Method (Date)