Search code examples
node.jsmongodbexpressmongooseapollo

How to save DateTime to MongoDB with Timezone intact?


Hi Im trying to save time and date to Mongo DB but it seems to be changing the date to another format and even when I try in that format it removes the timezone and changes the time

2022-03-30T09:00:46-07:00

becomes

2022-03-30T16:00:46.000+00:00

*My issue is when I send emails to tell clients the time it sends the wrong time completely causing confusion. How can I ensure the timezone get saved in Mongo.

Im using graphql as an api lang if needed.


Solution

  • There was no way to do it. It's best to store timezone separate and convert