2016-10-17 3 views
0

우선이 주제와 관련된 몇 가지 질문을 찾을 수 있습니다. 그러나 나는 할 수 없었다. 이것은 내 코드를 요구하는 솔루션입니다.PHP에서 Mongodb의 두 날짜 사이의 주문 세부 사항

Javascript 날짜가 포함 된 Ajax에서 두 날짜가 전송됩니다.

var sd = new Date("2016-10-15T00:00:00.000Z"); 
var ed = new Date("2016-10-17T00:00:00.000Z"); 
$.ajax({ 
      type: "GET", 
      url: "dashboard/load_revenue_chart", 
      data: {type:"revenue",period:"no of days",start_date: sd.getTime(),end_date: ed.getTime()}, 
      dataType: 'json', 
      success: function(data){ 
      line_chart(data); 
     } 
    }); 

컨트롤러 :

if (isset($_GET['period'])) { 

     $collection = $this->selectCollection(); // public function for setting the collection.   
     $start = $_GET['start_date']; 
     $end = $_GET['end_date']; 
     print_r($_GET['start_date']); // Outputs : 1476489600000 
     print_r($_GET['end_date']); // Outputs : 1476662400000 

     $result = $collection->find(array("OrderedOn" => array('$gt' => $start, '$lt' => $end))); 
     print_r($result); 
} 

출력 :

MongoCursor 개체 ( )

도 ISOString으로 노력했다. 출력을 얻을 수 없습니다. 그러나 Mongo Shell과 같은 것을 시도 할 때 결과를 얻을 수 있습니다.

나는 실종 된 것을 모른다. PHP로 결과를 얻는 방법을 설명해 주시면 큰 도움이 될 것입니다.

미리 감사드립니다.

답변

0

이 시도 :

$dateRange = $collection->find(array("timeStamp" => array('$gt' => $start, '$lt' => end))); 
where $start is the start date & $end is the end date 
+0

은 동일했습니다. 결과가 없습니다. 어떤 형식으로 시작일과 종료일을 알려줘야합니까? –