Home > database >  Best method to detect if the browser Time Zone is Nepal UTC 5:45 NPT
Best method to detect if the browser Time Zone is Nepal UTC 5:45 NPT

Time:03-16

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?

CodePudding user response:

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

CodePudding user response:

<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>
  • Related