getUTCHours() to read Hour of GMT

We know how to get local computer ( client computer ) time by using getHours function. However to get the UTC time or GMT we have to use getUTCHours function. This function uses the local time setting and calculates the corresponding GMT time. We can check the difference between the two but before that here is the syntax with an example.
<script type="text/javascript"> 
var dt= new Date();
document.write("using getUTCHours : ");
document.write(dt.getUTCHours());
</script>
We can compare the output using getHours() and getUTCHours()

<script type="text/javascript"> 
var dt= new Date();
document.write("using getHours : ");
document.write(dt.getHours()); 
</script>
<br><br>
<script type="text/javascript"> 
var dt= new Date();
document.write("using getUTCHours : ");
document.write(dt.getUTCHours()); 
</script>
Here is the output of above code.




You can see the difference in getHours and getUTCHours in above code. You can also read the difference in these two times by using getTimezoneOffset() function
Your Rating





More on JavaScript Date & Time

Post Comment This is for short comments only. Use the forum for more discussions.




HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer