What's the best way to store timestamps in MongoDB?
Which format is best:
# "created": { "d" : "2010-03-29", "t" : "20:15:34" } # "created": "12343545234" # seconds since epoc # "created": "2010-03-14T21:20:14+0000"
Is there a way to have MongoDB automatically set created
and updated
fields?
Which format is best
Best for what?
Is there a way to have MongoDB automatically set created and updated fields?
Created time is in the ObjectId but, as far as I know, you will have to update a updated
field manually.
Example:
ObjectId("538141a9615760fd04ffef5f").getTimestamp()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With