JavaScript getUTCHours() | Get the UTC Hour

The JavaScript getUTCHours() method is used to get the hour (0-23) according to Universal Time Coordinated (UTC) or Greenwich Mean Time (GMT). For example:

HTML with JavaScript Code
<!DOCTYPE html>
<html>
<body>
   
   <p id="xyz"></p>

   <script>
      const d = new Date();
      let hour = d.getUTCHours();
      document.getElementById("xyz").innerHTML = hour;
   </script>

</body>
</html>
Output

JavaScript getUTCHours() Syntax

The syntax of getUTCHours() method in JavaScript is:

x.getUTCHours()

where x must be an object of the Date() constructor.

The getUTCHours() method returns a number from 0 to 23 which will be the hour of the UTC time.

JavaScript Online Test


« Previous Tutorial Next Tutorial »