thesunneversets
thesunneversets

Reputation: 2580

CakePHP Queries involving DateTime

I'm having some trouble working out how to do comparisons on a datetime field, in the course of a CakePHP query.

I want for instance to be able to periodically delete all records from my database that relate to an event that occurred in the past. But I haven't gotten much further than:

$this->Item->deleteAll(
  'conditions'=>array('date'=> ... ),
  false
 );

Given that date is stored as a datetime, what's a good way of asking CakePHP to delete all items where the date is earlier than today?

Upvotes: 1

Views: 2229

Answers (1)

deceze
deceze

Reputation: 522081

'conditions' => array('Item.date <' => date('Y-m-d'))

Upvotes: 4

Related Questions