How to Get User Timezone in Javascript?

Hi guys Today, I will tell you through this tutorial that how to get the location of any user from the user’s timezone javascript script code.
First of all you can create an html file. You can keep any name for this file.

timezone.html

 
<script>
console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)
</script>

You can also write this code like this.

<script>
var timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
alert(timezone);
</script>