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
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    Post your comments , suggestion , error , requirements etc here .




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer