【发布时间】:2013-10-15 05:55:33
【问题描述】:
我知道你可以手动完成,但这不是重点。我需要把今天的日期放在我的 mongoDB 查询中并让它工作。
手动以下工作正常。
$cursor = $collection->find(array("date"=> array('$gt' => '01/10/2013')));
但是当我使用以下内容时
$date = date('d/m/Y');
$cursor = $collection->find(array("date"=> array('$gt' => '$date')));
没有用
我试过了
$cursor = $collection->find(array("date"=> array('$gt' => $date)));
$cursor = $collection->find(array("date"=> array('$gt' => "'".$date."'")));
$cursor = $collection->find(array("date"=> array('$gt' => \"$date\")));
以上方法均无效
【问题讨论】:
-
尝试使用
MongoDate:php.net/manual/en/class.mongodate.php
标签: php arrays mongodb date datetime