duanhan3067 2015-07-21 01:03
浏览 80

使用php错误从mongodb中选择时间

I was trying to query from mongodb using php, my database looks like this

{
    "_id" : ObjectId("55892817d4302e281b8b4567"),
    "subject" : "Report",
    "createdAt" : ISODate("2015-06-23T09:34:15Z"),
    "processedAt" : ISODate("2015-07-23T09:34:15Z"),
    "testNumber" : 10
}

and my query is:

$procInMins = 60;
$anchor = new \DateTime('now', new \DateTimeZone('UTC'));  // now
$anchor->sub(new \DateInterval('PT' . $procInMins . 'M'));
$query = array( "subject" => "Report", "processedAt" => array( '$gt' => $anchor));
$cursor = $collection->find($query);

and this returns a cursor whose count is 0, but i also tried

$query = array( "subject" => "ProcessOverflowSmsLogCommandTest Report", "testNumber" => array('$gt'=>3) );

in this case i compare the testNumber field and it returns 1 result, which is correct. So i think there's something wrong with the date, but I have no idea how to fix this. Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 winform的chart曲线生成时有凸起