Home »
        JavaScript
    
    Date getUTCHours() method with example in JavaScript
    
    
    
    
        JavaScript Date getUTCHours() method: Here, we are going to learn about the getUTCHours() method of Date class with Example in JavaScript.
        
            Submitted by IncludeHelp, on March 08, 2019
        
    
    
    JavaScript Date getUTCHours() method
    getUTCHours() method is a Date's class method and it is used to get hours from the current time according to the UTC (Universal time coordinated).
    
Syntax
var dt = new Date();
dt.getUTCHours();
        
Sample Input/Output
Input:
var dt = new Date();
dt.getUTCHours();
    
Output:
22
JavaScript code to get the current UTC hours using getUTCHours() method
<html>
<head><title>JavaScipt Example</title></head>
<body>
<script>
	var dt = new Date(); //Date constructor 
	var hr1 = dt.getUTCHours(); //UTC hours 
	var hr2 = dt.getHours(); //local hours
	//printing hours
	document.write("UTC hours = " + hr1 + "<br>");
	document.write("Local hours = " + hr2 + "<br>");
</script>
</body>
</html>
Output
UTC hours = 17
Local hours = 22
    Reference: JavaScript getUTCHours() Method
	JavaScript Date Object Methods »
	
	
    
    
    
    
    
  
    Advertisement
    
    
    
  
  
    Advertisement