I want to query a collection and get documents which have created less than 3 hours ago.
$realtime = date("Y-m-d H:i:s");
$mongotime = New Mongodate(strtotime($realtime));
$mongotime = $mongotime - 3 hours; //PSEUDOCODE
$some_condition = array('time' => array('$lt'=>$mongotime) );
$result = $db->collection->find( $some_condition );
Is there an effective way to put
$some_condition
part without using IF statement in PHP?
I have found the solution.