Filter Date using Date Picker in Yii
- by era
I have generated my crud screens using gii.. I have a search form, where i have put a date picker, where i give the user to select the date he wants.
But the problem is that i have the date stored in seconds in the database.
and i know that i can convert the date using strtotime. But then how do i filter using the search method in my model?
this is my date picker
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>'ordering_date',
'id'=>'ordering_date',
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
));
?>
and this is my search method in my model. I want to compare the ordering_date
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
//echo $this->ordering_date;
$criteria=new CDbCriteria;
$criteria->compare('order_id',$this->order_id);
$criteria->compare('customer_id',$this->customer_id);
$criteria->compare('delivery_address_id',$this->delivery_address_id);
$criteria->compare('billing_address_id',$this->billing_address_id);
$criteria->compare('ordering_date',$this->ordering_date);
$criteria->compare('ordering_done',$this->ordering_done,true);
$criteria->compare('ordering_confirmed',$this->ordering_confirmed);
$criteria->compare('payment_method',$this->payment_method);
$criteria->compare('shipping_method',$this->shipping_method);
$criteria->compare('comment',$this->comment,true);
$criteria->compare('status',$this->status,true);
$criteria->compare('total_price',$this->total_price);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}