CGridView provides inbuilt search system but for individual columns. I have a date column in my record and i want to search not only for specific date but for a range of dates. How to do this in Yii?
CGridView provides inbuilt search system but for individual columns. I have a date column
Share
Couple ways of doing it. I’m not sure if Yii has something built in for dates, however this is what I would do store your date as time() as its much easier to work with and will help you in the longer run. Once you have the time as epoch, I would have a function that took user input covered it to epoch time. and all you would have to do is use the > or < to search for the range.
In your search function for your model
i would do this for the date field:
$criteria->compare(‘date’,$this->getSwitch($this->date), true);
now inside the model create a new function called getSwitch() or what ever you want to name it.