user8762292
user8762292

Reputation:

automatically convert GMT time

when I print the Date() it brings me the schedule of my machine, but I have a website that is accessed by different parts of the world and I need to show on the site the schedule of only a certain Country "BRAZIL" GMT 0300

Can someone help me ?

how to automatically convert the time showing in the application, regardless of where the user is accessing.

Upvotes: 1

Views: 159

Answers (1)

peter bray
peter bray

Reputation: 1345

Use toLocaleString() and specify a timezone like this:

console.log(
  new Date().toLocaleString("en-US", {timeZone: "America/Sao_Paulo"})
);
// 5/19/2018, 1:04:43 PM = Time in Brazil

Here is a list of timezones you can use.

Upvotes: 2

Related Questions