I am trying to do something in node.js
So now if a user inputs a date, example 21/10/2020 at 1pm, I would like to create a Date() object with that date but adjusted to the User's timezone. The only information I have about the timezone is the IANA(?) name, such as "Asia/Shanghai"
so is there anyway to do something like
const adjusted = new Date(2020, 9, 21, 13, 0, 'Asia/Shanghai');
to get the correct date? I am open to using packages.
Edit: Similarly, is there any easy packages out there to find the time offset (e.g. UTC + x) given the name? For example it would return +8 if the input is 'Asia/Shanghai'
Edit 2: To anyone else who came upon this, you can do what I want using dayjs. for example, dayjs.tz("2020-12-01 12:30", "Europe/London") would give you a dayjs object with the correct time stamp.