I am reading in a variable string, DateTime = "2019-11-21T08:29:56EST", from another file. The format of this string with the 'EST' is a outlier for my files. I want to identify this time as EST, remove the characters of "EST" from the string or obtain just the time "2019-11-21T08:29:56" and convert the time to UTC. Here is what I have tried so far. I think dayjs is assuming DateTime is in UTC which is preventing th conversion from happening.
var dayjs = require('dayjs');
var utc = require('dayjs/plugin/utc');
var timezone = require('dayjs/plugin/timezone'); // dependent on utc plugin
dayjs.extend(utc);
dayjs.extend(timezone);
var DateTime = "2019-11-21T08:29:56EST"
var split_DateTime = DateTime.split("EST")
if (DateTime.includes("EST")) {
var UTC_DateTime = dayjs.tz(split_DateTime[0]).tz("UTC").format('YYYY-MM-DDTHH:mm:s');
} else{
var UTC_DateTime = split_DateTime[0];
}