I live in Arizona which does not observe Daylight Saving Time. I have a string date/time that I want to convert to different time zones.
var stringDateTime = "20181022090522";
stringDateTime = convertTimeZone(stringDateTime, "US/Arizona", "US/Eastern");
alert (stringDatetime);
Output would be "20181022120522" (Eastern Time is currently 3 hours ahead of Arizona time, time changes from 9:05AM to 12:05PM). However, after Daylight Saving goes, Eastern Time would be 2 hours ahead of Arizona. So an input of "20181201050954" would output "20181201070954" (time changes from 05:09AM to 7:09AM).
I need the "convertTimeZone" function to take the input of the string, the timezone it originates from, and the timezone to convert to. The string input and output will always be yyyyMMddHHmmss.
I also need to make sure the date part gets updated if it's close to midnight.
var stringDateTime = "20181231234502"; // (12/31/2018 11:45:02PM)
stringDateTime = convertTimeZone(stringDateTime, "US/Arizona", "US/Eastern");
alert (stringDatetime);
Output would be "20190101014502" (1/1/2019 1:45:02AM).
I need to be able to do this without involving any external javascript libraries (I can't use moment.js etc). Most of the examples I've seen have needed this or a similar library.