How to use getUTCHours in JavaScript
In this article, I will explain use of getUTCHours() method in JavaScript date object.
JavaScript date getUTCHours() method
-
getUTCHours() method of date object returns the hour of the specified date according to UTC.
-
In getUTCHours() method, The returned value is an integer number between 0 and 23.
-
UTC is the time set by the World Time Standard.
Syntax
Example
In the following example show to getUTCHours() method returns current hours according to universal time.
<!DOCTYPE html>
<html>
<body>
<h3 style="color:Blue">JavaScript getUTCHours() Method Example</h3>
<p id="demo">Click for display the hour, according to UTC.</p>
<button onclick="myFunction()">Click ON</button>
<script type="text/javascript">
function myFunction() {
var d = new Date();
var x = document.getElementById("demo");
x.innerHTML = d.getUTCHours();
document.write("UTC Hours of the Current Time: " + d.getUTCHours());
}
</script>
</body>
</html>
|
Output1

Output2

You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here