I need to add/remove the local offset (timezone) to a UTC string I get from a Rest API. So, say for instance I received the following from my server, 2040-09-23T22:00:00.000Z
I wish add or remove the local UTC offset which I determine using return new Date().getTimezoneOffset();
in a separate function.
So to add/remove the local time zone I do something like this, notice my main function, then the helper function and how I try to determine the local time
function makeLocalTime(utcFromServer) {
return new Date(utcFromServer + (getOffSet() * 60 * 1000));
}
function getOffSet() {
return new Date().getTimezoneOffset();
}
var localTimeUTCwithOffset = makeLocalTime('2040-09-23T22:00:00.000Z');
However this returns an error with the message Invalid Date. Any ideas where I am going wrong?