Home >>JavaScript Date Object Methods >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();
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
getUTCHours() | Yes | Yes | Yes | Yes | Yes |
<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>
<html> <body> <script> var dateobj = new Date('february 25, 2020 GMT+10:00'); var B = dateobj.getUTCHours(); document.write(B); </script> </body> </html>