'Best method to detect if the browser Time Zone is Nepal UTC +5:45 NPT

What is the best method on browser-side to detect the Nepal Time-Zone?

https://www.timeanddate.com/time/zone/nepal

The code should work both in the newest and older browsers such as Iexplorer.

zone = Intl.DateTimeFormat().resolvedOptions().timeZone

What value should I expect for NEPAL and does the above code work in IE too? Would it be better to use jstimezonedetect library instead?



Solution 1:[1]

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.23/moment-timezone-with-data-2012-2022.min.js"></script>
<script>
  document.getElementById('guess').innerText = moment.tz.guess();
</script>

Solution 2:[2]

Intl.DateTimeFormat().resolvedOptions().timeZone === 'Asia/Katmandu'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tom
Solution 2 Ouroborus