Is there a difference between using PHPs time() and using new MongoDate()?
I need to store created_at and updated_at dates for each documents in by mongoDB collection
so that I can query them by date (for example documents updated last week).
From what I can see time() and new MongoDate() produces the same result?
That’s because
time()is default for theMongoDateconstructor, from the manual:You should use
MongoDateobjects to query MongoDB.If you use the raw output of
time(), you will store/query for an integer. When you useMongoDate, you will be using MongoDB’s Date type which gives you some additional benefits.