I'm trying to fetch coupons that haven't expired yet. I have this in my controller:
public function coupons() {
$this->paginate['Coupon']=array(
'limit'=>9,
'order'=>'RAND()',
'conditions'=>array(
'Coupon.end_date'=>??????)
);
$c=$this->paginate('Coupon');
$this->set('allcoupons', $c);
}
I need it to return all records not expired as of today. end_date is in DATE format. I don't know how to ask cake to look at end_date and compare it to today, AND do it inside the paginate method.
You just need to format your date properly
'Coupon.end_date >' => date('Y-m-d H:i:s')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With