Date getUTCHours() Method - Javascript Date

Javascript examples for Date:getUTCHours


The getUTCHours() method returns the hour (from 0 to 23), according to universal time.

UTC time is the same as GMT time.



Return Value:

A Number, from 0 to 23, representing the hour

The following code shows how to return the hour, according to universal time:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {//from  www.jav  a2 s.  c o  m
    var d = new Date("July 21, 2020 01:15:00");
    var n = d.getUTCHours();
    document.getElementById("demo").innerHTML = n;


Related Tutorials