Saya memiliki koleksi khusus yang ingin saya filter berdasarkan tanggal dibuat dan het entri dibuat "kemarin"
Entri Koleksi
//dates are set in controller using
setCreatedTime(Mage::getModel('core/date')->gmtDate());
Dibuat Kemarin (tidak berfungsi)
//3 products items Yesterday
//below filtering outputs incorrect entries
$collection = Mage::getModel('things/things')->getCollection();
Saya sudah mencoba, tetapi menampilkan entri yang salah;
//thought strtotime('yesterday') would work..
$collection->addFieldToFilter('created_time', array('gt' => Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('yesterday'))));
$collection->addFieldToFilter('created_time', array('gt' => Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('-1 day'))));
$collection->addFieldToFilter('created_time', array('from'=> strtotime('-1 day', time()),'to'=> time(),'datetime' => true));
$fromDate = date('Y-m-d H:i:s', strtotime($fromDate));
$toDate = date('Y-m-d H:i:s', strtotime($toDate));
$collection->addFieldToFilter('created_time', array('from'=>$fromDate, 'to'=>$toDate));
Dibuat Hari Ini (Hari ini) (berfungsi)
//5 products items today with timestamp 2016-05-01 05:22:53
//below filtering outputs correct entries
$collection = Mage::getModel('things/things')->getCollection();
$collection->addFieldToFilter('created_time', array('gt' => Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('today'))));
Dibuat minggu lalu (karya)
//23 products items with timestamps for this week
//below filtering outputs correct entries
$collection = Mage::getModel('things/things')->getCollection();
$collection->addFieldToFilter('created_time', array('gt' => Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('-1 week'))));