I'm developing my first commercial project using MongoDB. Otherwise very pleased with the quality of the product and documentation, but the corner of handling local times would seriously need more effort, either in the API and/or a tutorial describing good practices.
StackOverflow.com has multiple cases where people are equally puzzled by this, it's not only me. It should be easy and explicit to:
- save UTC date and retrieve one, without conversions to the local time zone
- save local time and retrieve one, as above
Our customer case is that we want UTC time stamps for the normal reasons, but also wish to see what "wall clock time" and e.g. day of week the stored data fits, in the local context. A tutorial describing how to do this would have helped.
- should we store local times as BsonDateTime (as if they were UTC)
- should we store using "minutes from the beginning of the week" (fine grained time would come from the UTC time stamp)
- should we do something else?
I think much of the confusion is due to Joda DateTime. I'm considering not using it, later, and dealing with BsonDateTime objects directly. However, for now things are reasonably okay so this must wait.
Other things being so nice and trivial with MongoDB, how about fixing the local time corner as well?
Links to StackOverflow issues regarding these:
http://stackoverflow.com/questions/26023835/how-to-read-back-a-datetime-as-utc-in-mongodb-casbah
http://stackoverflow.com/questions/16901393/storing-utc-and-local-datetime-in-mongo
- related to
-
DOCS-4082 Update documentation on timestamp constructor
- Closed