Why can’t I take a time and set it to another zone? I want to take a string of a date and time that is static and change it to a different time zone and get result.
var d = new Date("2022-05-18T19:48:32.000+00:00");
d.toLocaleString('en-US', { timeZone: 'America/New_York' });
alert(d);
No matter what I do, it says my local computer time on my computer in Denver.
>Solution :
d.toLocaleString('en-US', { timeZone: 'America/New_York' }); returns a string, but you’re not setting it to a variable. Try d = d.toLocaleString('en-US', { timeZone: 'America/New_York' });