0
array:4 [▼
  "_id" => ObjectId {#1108 ▶}
  "Date" => UTCDateTime {#1112 ▼
    +"milliseconds": "1591399800000"
  }
  "token" => "1013875"
  "value" => "78.65"
]

Hi, The sample object is as above, I need to get data(collection) where the Date is equal to 1591399800000(Time in milliseconds). Db is Mongo DB, Laravel framework.

DB::table('table_name')->where('Date','1591399800000')->first();

not giving me the required output.

Dinesh Naik
  • 17
  • 1
  • 4
  • I am not a Laravel expert (or even beginner) but I am willing to that `where('Date','1591399800000')` is treating `1591399800000` as a string, not integer number of milliseconds. You need to do something like `where('Date',' UTCDateTime(1591399800000))` – Buzz Moschetti Jun 06 '20 at 19:17

1 Answers1

0

I have done like this and getting required results:

$start_time = new \DateTime('-5 minutes');

$end_time=new \DateTime('-4 minutes');

DB::table('table_name') 
   ->where('Date',array('$gte' => $start_time,'$lte' => $end_time)) 
   ->first()
Dinesh Naik
  • 17
  • 1
  • 4