Wednesday, June 10, 2015

How to get the current timezone with Javascript

Please include these cdns into your HTML document.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js"></script>

Invoke the script by calling:

> var timezone = jstz.determine();
> timezone.name();
"Asia/Kolkata"