我想查询一个集合并获取不到3小时前创建的文档.
$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 );
是否有一种有效的方式
$some_condition
部分没有在PHP中使用IF语句?
我找到了解决方案.
原文链接:https://www.f2er.com/php/130633.html$diff = 60 * 60 * 3; //3 hours in seconds $mongotime = New Mongodate(time()-$diff); $condition = array('time' => array('$lt'=>$mongotime) ); $result = $db->collection->find( $condition );