Phoste
Phoste

Reputation: 1209

Incorrect date in mongodb

I am inserting a lot of documents with a date in mongodb but the time doesn't match...

The time on the document is 1 hour early from the inserted time. Is it my mongo server who's not well configured ? Or do I have to do something else ?

I insert all the documents with a java application.

Thanks

Upvotes: 1

Views: 4033

Answers (1)

innoSPG
innoSPG

Reputation: 4656

You possibly have 1 hour time difference compared to UTC. You have to account for your locale because mongodb store date as UTC timestamp.

MongoDB stores times in UTC by default, and will convert any local time representations into this form. Applications that must operate or report on some unmodified local time value may store the time zone alongside the UTC timestamp, and compute the original local time in their application logic.

Also see this page for more details.

Upvotes: 3

Related Questions