'how to set exact same date with momentjs in any environment?

I'm trying to set a date to a particular timezone with the following function:

const setDate = moment("2022-04-03T19:23:00").tz(ENV.TZ,true);

It's working well on my local however it is Not working once deployed, apparently I'm setting 1 day less for some reason. e.g.: in my local environment:

console.log(setDate); // Moment<2022-04-03T19:23:00+02:00>

somewhere in the cloud:

console.log(setDate); // Moment<2022-04-02T19:23:00+02:00>

any idea how to set a consistent timezone no matter what environment the code is running in?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source