Context:
I need to parse datetimes from UTC into the timezone currently set as default by moment-timezone with moment.tz.setDefault
.
Attempt (functional):
const task = {
startDate: '2020-03-24 14:00:00'
};
const startDateMoment = moment.utc(task.startDate).tz(moment().tz());
However, I am creating a new moment object every time I need to set the timezone. Is there a more performant way to converting between utc to the default timezone, or getting the default timezone from moment?
moment.tz.guess()
guesses the timezone from the browser, not the one set manually.
console.log(`default timezone: "${moment().tz()}", guessed timezone: "${moment.tz.guess()}"`);
returns
default timezone: "US/Samoa", guessed timezone: "America/Vancouver"