Reputation: 6000
I have option of storing date in mongo as ISO oject or timestamp in mongo.
Which one is more advisable and beneficial to use and why??
Upvotes: 5
Views: 3907
Reputation: 43884
Timestamp
data type is not for use by the end user ( http://php.net/manual/en/class.mongotimestamp.php ), this means that if you store a timestamp it will have no special abilities for date manipulation as it will be just an int
.
The "special" abilities you can get are mostly confined to Map Reduce and the aggregation framework whereby the valid date object (in the aggregation framework) is really the only reliable way to do time comparison.
So even though you can store the timestamp int
, and it would be smaller than the ISODate()
I would personally recommend not to.
Upvotes: 4