datetimeIn(date, timezone, optionalPrecision) could take a local time and shift it to another timezone.
Use case: “what time is it now in [somewhere far away]?”
How we could make it work:
- Read the UTC values of the provided
Date object.
- Do something with these values (sorry, should go to bed) and use
Intl.DateTimeFormat to transform the timezone to the specified location, e.g.:
new Intl.DateTimeFormat('en-GB', {
dateStyle: 'short',
timeStyle: 'long',
timeZone: 'America/New_York'
}).format(date); // '03/05/2021, 17:28:22 GMT-4'
- Compute timezones difference by comparing the GMT values and/or reparsing the output of 2.
- ??
(Also, check what Moments and others are doing.)
datetimeIn(date, timezone, optionalPrecision)could take a local time and shift it to another timezone.Use case: “what time is it now in [somewhere far away]?”
How we could make it work:
Dateobject.Intl.DateTimeFormatto transform the timezone to the specified location, e.g.:(Also, check what Moments and others are doing.)