How to get the Time Zone using Javascript?

To set your time zone using Javascript you may use as follows.

Code with examples


let CountryDate = new Date().toLocaleString("en-US", {timeZone: "Continent/Your City"});

An example based on New York:


toLocaleString('en-US', {timeZone: 'America/New_York'});

London would be like below:


toLocaleString('en-GB', {timeZone: 'Europe/London'});

As you may notice I specified a language as well.

Leave a Reply

Your email address will not be published. Required fields are marked *