Filter a Laravel collection by date -


in code given below $allzip["assigned_date"] has value 2016-07-27 18:12:26. when try compare created_at field timestamp field well, result empty collection.

$filtered_datas = $datas->filter(function ($data) use($allzip) {     return $data->zip == $allzip["zip"] && $data->created_at < $allzip["assigned_date"]; }); 

there data in database zip field matching value $allzip["zip"] , created_at field value 2016-07-19 18:12:26. should return 1 item in collection returns empty collection instead. why?

make sure dates datetime or carbon instances, not strings. otherwise, comparison operator shouldn't working expected.


Comments

Popular posts from this blog

Android volley - avoid multiple requests of the same kind to the server? -

magento2 - Magento 2 admin grid add filter to collection -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -