I am trying to use the moment.tz library however the dates keep changing in new timezones since the time is set at midnight (0:00:00). I would like the dates to be unchanged when changing timezones.
Essentially I have
const checkin = 2022-08-30T00:00:00.000Z <-- Date Object
console.log(moment.tz(checkin, 'YYYY-MM-DD HH:mm:ss', 'UTC') );
console.log(moment.tz(checkin, 'YYYY-MM-DD HH:mm:ss', 'America/Toronto') );
When I use the timezone America/Toronto, the date gets moved back a day since the time is midnight. This results in the following output:
Moment<2022-08-30T00:00:00Z>
Moment<2022-08-29T20:00:00-04:00>
My Goal is to have the moment function using time zone to reflect the same date (YYYY-MM-DD) as utc. The checkin date should not be changed based on timezone. Any Suggestions?