I am trying to create a Mongo query in PHP. I am working with a database created by someone else, and all the dates have been saved as strings. I want to find all the entries that were created before a certain time.
By searching online, I found that I should be able to use
array('updated_at' => array('$gt' => $access_date)))
where $access_date
is a MongoDate. Currently, I am using $access = new MongoDate(strtotime($access_date));
to create a MongoDate out of a date string.
But this only seems to work if update_at
was saved as a MongoDate object. As mentioned, it is saved as a string. Is there an easy way to use $gt
for date strings instead of MongoDates? If not I have to do a complicated for loop, and it is getting really messy.