First, find the time three hours before. Then the request is more than this time:
define('SECONDS_PER_HOUR', 3600); $mongotime = New Mongodate(time()-3*SECONDS_PER_HOUR); $condition = array('time' => array('$lt'=>$mongotime)); $result = $db->collection->find($condition);
There is no need to make some mark timestamp → string → timestamp (as you suggested), and you must name the constants that you use so that they understand what they represent.
hakre source share