[DOCS-4086] How to store local time in MongoDB? Created: 25/Sep/14 Updated: 17/Oct/14 Resolved: 17/Oct/14 |
|
| Status: | Closed |
| Project: | Documentation |
| Component/s: | manual |
| Affects Version/s: | None |
| Fix Version/s: | v1.3.12 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Asko Kauppi | Assignee: | Andrew Aldridge |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Casbah driver (Scala) on OS X |
||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Days since reply: | 9 years, 17 weeks, 5 days ago | ||||||||
| Description |
|
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:
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.
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: |
| Comments |
| Comment by Githook User [ 17/Oct/14 ] |
|
Author: {u'username': u'i80and', u'name': u'Andrew Aldridge', u'email': u'i80and@foxquill.com'}Message: Signed-off-by: kay <kay.kim@10gen.com> |
| Comment by Asko Kauppi [ 25/Sep/14 ] |
|
A third SO entry: http://stackoverflow.com/questions/12830521/how-to-translate-utc-time-to-arbitrary-local-time-in-mongo-j-s |
| Comment by Asko Kauppi [ 25/Sep/14 ] |
|
Ideally, the MongoDB API could allow storing "local time", maintaining the time zone information as well. If I store local time "as UTC", I will wipe out the time zone info. But most importantly, conversions between local and UTC (and the particular machine's local time zone, which may be yet something else) should not happen as implicitly as they now seem to happen. Any such conversions should be explicit, by the Scala compiler. |