Reputation: 977
I have an app that communicates to a MongoDB DB through a REST API running flask. I'm seeing time readings within the App to be 5 hours off - which makes me think its a time zone issue.
Ubuntu is showing me the correct time - Its formatted as per EST. Though, MongoDB - which I dont think has any awareness of timezone is displaying incorrect local time (even in UTC). When running db.serverStatus() i get a reply back saying:
"localTime" : ISODate("2013-12-13T21:15:16.663+19:00"),
Its about 9:15pm here on 12/12. So UTC, should be around 2:15am. I was expecting to see:
ISODate("2013-12-13T02:15:16.663+05:00").
Is my assumption correct on the expected ISODate object? How do I fix this?
Upvotes: 1
Views: 225
Reputation: 10522
It seems the MongoDB shell is reporting dates correctly.
ISODate("2013-12-13T21:15:16.663+19:00")
You said is about 2:15 AM, Dec 13 at your location, in UTC. That is 21:15 on a +19 hours offset, which is what MongoDB shows. I'm not sure why it is displaying the date with that offset?!?
Since you're the pymongo
driver, take a look at the tz_aware
option of the database connection classes. The default value is False
, which means you get naive dates on your application. Set to True
to get timezone aware dates.
Upvotes: 0