Aadesh Dhakal
Aadesh Dhakal

Reputation: 452

Moment Timezone conversion

I had a few concerns about using moment timezone conversion. I was using moment to convert to New York time from UTC using utcOffset. But later switched it to moment-timezone. The current implementation is:

console.log(moment(pickedDate).tz("America/New_York").format(format1));

The above implementation works properly. But, I had some questions. Like,

Upvotes: 0

Views: 79

Answers (1)

tauzN
tauzN

Reputation: 6951

Consider using something else that moment. Moment is no longer in active development. See this.

I use day.js myself, and I am very pleased.

Working with timezones and DST can be very cumbersome. I don't think anyone can answer your question perfectly here.

Consider the using the following approaches:

  • Make sure to always store date and time in the same timezone, and with no daylight saving information (like UTC)
  • Only convert to the desired timezone/DST on the client-side
  • Convert all dates and times back to UTC before sending to the server. (or make sure to define the timezone, and make sure the server can handle and convert back to UTC)

Upvotes: 1

Related Questions