I display my date in CGridView as: “22.6.2012 22:53” with:
array('name' => 'date',
'value' => date("j.n.Y G:i", strtotime($model->date))
),
But in my filter, I need to search in this format (which is in the database) to get results: “2012-06-22 22:53”.
How can I make my filter to work in the format that is displayed in my CGridView? I’ve searched for an answer but haven’t found one, I’ve also tried adding the date function in my model search() for this attribute:
$criteria->compare('date', date("j.n.Y G:i", strtotime($this->date), true);
but then I just get an empty list 🙂
Help would be greatly appreciated.
compare() makes a sql sentence with the input, so I had to change the input to my wanted format.
my function:
With this, a user can enter date in the format “j.n.Y H:i” and also just portions of this format (j.n, n.Y, Y H:i,…).
I would like to thank Jon and nickb for help! link