Home >>JavaScript Date Object Methods >JavaScript getUTCHours() Method

JavaScript getUTCHours() Method

JavaScript getUTCHours() Method

The getUTCHours() method is an inbuilt method in JavaScript which is used to returns the hour ( from 0 to 23) in the specified date according to universal time.

Syntax:
DateObj.getUTCHours();

Browser Support

Method Chrome Edge Firefox Safari Opera
getUTCHours() Yes Yes Yes Yes Yes
Here is an example of JavaScript getUTCHours() Method:
<html>
<body>
<button onclick="myUTCdate()">Click me</button>
<p id="Date"></p>
<script>
function myUTCdate() 
{
  var d = new Date();
  var a = d.getUTCHours();
  document.getElementById("Date").innerHTML = a;
}
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
<script> 
var dateobj = new Date('february 25, 2020 GMT+10:00'); 
var B = dateobj.getUTCHours(); 
document.write(B); 
</script> 
</body>
</html>
Output:

No Sidebar ads