In PHP & MongoDB, i am trying to read all instances of events for a specific calendar and a specific period. Each event has start and end date. They are of MongoDate type in mongodb.
I use below condition to get the events from mongo.
$condition = array(
'start_time' => array('$gte' => new MongoDate($start_day)),
'end_time' => array('$lte' => new MongoDate($end_day))
);
Here is my problem, i am missing the events whose start date is to my date range.
For example
event starts on 01-july-2014
event ends on 10-july-2014
my mongo query - give me events from 5-july to 12-july
$condition = array(
'start_time' => array('$gte' => '5-july-2014'),
'end_time' => array('$lte' => '12-july-2014')
);
When i run above mentioned event is not returned.
Any suggestions are welcome?
In mysql BETWEEN helps me to get the required results.