Friday, February 7, 2014

Get gmt time and gmt diferrence using jQuery


<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script>
    $(document).ready(function() {
        var rightNow = new Date();
        $("div").append("Local time: " + rightNow + "<br/>");
        var temp = rightNow.toGMTString();
        $("div").append("GMT time: " + temp + "<br/>");
        var visitorTimeZone = "GMT " + -(rightNow.getTimezoneOffset() / 60);
        $("div").append(visitorTimeZone + "<br/>");
    });    
</script>
<div class="div"></div>

No comments:

Post a Comment