0

I want to filter order collection using 'created_at' attribute but the problem is, values stored in 'created_at' attribute is in this format 2014-03-18 06:57:11 (Combination of date and time) and I want to apply filter with only this format 2014-03-18(Date without time).

Please suggest me some solution.

1 Answer 1

3

You can filter collection by this code

$from = date("Y-m-d 00:00:00"); // current date
$ordersList=Load order collection
$ordersList->addFieldToFilter('created_at', array('from' => $from));

Or you can pass value like below

$to = date("Y-m-d h:i:s"); // current date
$from = strtotime('-24 hours', strtotime($to));
$from = date('Y-m-d h:i:s', $from); // 24 hours before
$ordersList=Load order collection
$ordersList->addFieldToFilter('created_at', array('from' => $from));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.