Thursday, February 23, 2012

cakePHP ‘created’ truncated to the date only

September 7, 2010 by Ayo Akinyemi · Leave a Comment 

$this->yourTableName->find(“all”,array(‘conditions’ => array(‘yourTableName.id’ => $this->params['pass'][0], ‘DATE(yourTableName.created) ‘ => date(“Y-m-d”,strtotime(“-0 day”)))));

‘created’ DB column name in cakePHP has a datetime format. the code finds record using the date(“Y-m-d”) condition.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

You must be logged in to post a comment.