JavaScript getUTCHours Function

JavaScript getUTCHours function is one of the Date Functions, which returns the total number of hours on a given date according to universal time. The syntax of the getUTCHours function is:

 Date.getUTCHours()

JavaScript getUTCHours Example

I am using the getUTCHours to return the total number of hours as per the universal time from the current date and time.

<!DOCTYPE html>
<html>
<head>
    <title> JS </title>
</head>
<body>
    <h1> Example </h1>
<script>
  var dt = Date();  
  document.write("Date and Time : " + dt);
  document.write("UTC Hours : " + dt.getUTCHours());
</script>
</body>
</html>
Example

Date and Time: Mon Nov 05 2018 10:54:43 GMT+0530 (Indian Standard Time)
UTC Hours : 5

getUTCHours Example 2

In this JavaScript get UTC Hours example, we display the universal time hours from the custom date.

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript Get UTC Hours Function </title>
</head>
<body>
    <h1> JavaScriptgetUTCHoursFunctionExample </h1>
<script>
  var dt = Date("April 2, 2017 10:11:22");
  document.write("Date and Time : " + dt);
  document.write("UTC Hours using getUTCHours : " + dt.getUTCHours());
</script>
</body>
</html>
JavaScript getUTCHours Example

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.