How to change the data timezone in mongodb atlas

Hi All,

is it possible to change default data timezone on mongodb atlas?

Thank you.

Hi @Watri_Wahab and welcome in the MongoDB Community :muscle: !

I’m not sure which TZ you are talking about.

Each Atlas project have a custom TZ that you can modify here:

But if you are talking about the TZ in the actual ISODate values that you are storing in your cluster, it depends on the back-end code that is generating these dates. MongoDB doesn’t interfere with the data that is being stored. Send X => Store X.

The TZ in the Project Settings doesn’t affect any of the data. It’s just for the metrics, alerts, windows maintenance, etc.

That being said, MongoDB can transform the ISODate you stored and present them in the TZ of your choice.

If I remember correctly, all these operations support an optional timezone field.

Cheers,
Maxime.

3 Likes

Hi @MaBeuLux88,
Thanks for answer my question.
Yes, I mean the timezone of data collection.
As per I know, the default timezone is UTC. If I want to change the timezone, I need generate the date on application side. Is it correct?

Cheers
Watri

Yeah I think it’s fair to say that.

I’m in Paris right now so my current TZ is UTC+2. It’s currently 15:51 local time in Paris. But if I create a new date in MongoDB, it’s going to be 13:51 UTC+2.

test [direct: primary] test> db.coll.insertOne({date: new Date()})
{
  acknowledged: true,
  insertedId: ObjectId("62a9e3e50c008ec5fa9c6caf")
}
test [direct: primary] test> db.coll.findOne()
{
  _id: ObjectId("62a9e3e50c008ec5fa9c6caf"),
  date: ISODate("2022-06-15T13:51:33.388Z")
}

Take a look at this topic as well. This might help.

Cheers,
Maxime.

2 Likes

Hi @MaBeuLux88,
Thanks for the answer and detail explain.

Cheers
Watri

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.