Mongodb ISODate格式比较在PHP中不起作用



我有一个像"estdate" : "2016-06-14T06:49:00.000Z"
这样的mongodb记录 我正在编写以下php代码来查询时间

$from=$start = new MongoDate(strtotime('2016-04-11 00:00:00'));
 $to=new MongoDate(strtotime('2016-06-18 00:00:00'));
 $filterpatient = array("order.patientinfo.order_id" => $ordertext,"order.orderitem.estdate" => array('$gte' =>$from, '$lte' => $to));
 $cursor = $collection->find($filterpatient)->sort(array('_id'=>-1)); 

但这没有结果。

如果您使用的是mongodb驱动程序,这可能对您有所帮助。

$starttime = strtotime("2016-04-11 00:00:00");$utcstartdatetime = new MongoDB\BSON\UTCDateTime($starttime);

现在,使用查询中的$utcstartdatetime来获取时间。

最新更新