I'm using PHP as server side language. I'm getting date in millisecond from my ajax request and converted it into MongoDate, then i store it into MongoDB. Like below.
$date = new MongoDate($millisecond / 1000);
$db->test->insert({"date": $date});
Again, when i need date in my javascript, i'm getting MongoDate and and converted into millisecond and i pass it to my UI. Like below
foreach($cursor as $row) {
$row["date"] = $row["date"]->sec * 1000;
}
Instead, why should i not store date as millisecond instead of Dateobject? Still i can compare two dates, even-though i store it as millisecond.
Any other disadvantages would i face in future, while i do reports with date as millisecond?
Currently the only place I can think of where it would matter if a date field were actually stored as the ISODate
type is within the aggregation framework, however, I have no doubt that such a constraint will eventually change when casting becomes possible (this I would like to see).
Other than that your value is easily usable within both PHP/any other language and Map Reduces own date constructs. With this in mind I see no problem if you don't require the aggregation frameworks date operators.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.