Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have multiple clocks showing multiple timezones #18

Closed
patriciagoh opened this issue Dec 24, 2019 · 1 comment
Closed

Have multiple clocks showing multiple timezones #18

patriciagoh opened this issue Dec 24, 2019 · 1 comment
Assignees
Labels

Comments

@patriciagoh
Copy link

If I have multiple clocks and using the basic usage code, what's the best approach to mutate the state to show a different timezone for each clock?

E.g
Clock 1: UTC-6
Clock 2: UTC-5
Clock 3: UTC-2

Thanks!

@wojtekmaj wojtekmaj self-assigned this Dec 26, 2019
@wojtekmaj
Copy link
Owner

Date in JavaScript doesn't have a concept of timezones really, it only uses local time and allows to get local and/or UTC string out of it if needed. This makes displaying time from non-local timezone very tricky.

So for example if you're in London, and would like to show clocks from UTC and UTC+1, you would use:

  • new Date() for your current time (UTC)
  • Something like new Date(new Date().toISOString().slice(0, -1) + '-01:00') for UTC+1. Why? We're looking for a date which, when read as our local time, will return a time an hour later than our current one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants