I have a date with a time, like this
const date = {year: 2020, month: 12, day: 31};
const time = {hours: 16, minutes: 2};
How do I get UTC representation of that time depending on a timezone? (without using any libraries)
convetToUTC(date, time, "Europe/Moscow") // => <UTC timestamp>
convetToUTC(date, time, "America/New_York") // => <UTC timestamp>
Examples
convetToUTC(
{year: 2021, month: 7, day: 30},
{hours: 16, minutes: 15},
"Europe/Moscow"
) // => 1627650900
convetToUTC(
{year: 2021, month: 7, day: 30},
{hours: 16, minutes: 15},
"America/New_York"
) // => 1627676100