'timezone conversion based on user's timezone

I'm working on an app that returns EST time. I want to convert EST time to the user's local timezone.

eg: EST: 2022-03-23T21:00:00.000Z

PKT: 2022-03-24T06:00:00.000Z

Sydeny: 2022-03-24T12:00:00.000Z



Solution 1:[1]

I think time zones will be selected by default with your location ( local one ). However to convert it into another one you can use moment js library.

const moment = require('moment-timezone')

const start = moment.tz("2021-12-08T10:00:00", "UTC") // original timezone

console.log(start.tz("America/Los_Angeles").format())
console.log(start.tz("Asia/Calcutta").format())
console.log(start.tz("Canada/Eastern").format())

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Asad Ashraf