Filter Date using Date Picker in Yii

Posted by era on Stack Overflow See other posts from Stack Overflow or by era
Published on 2012-06-06T06:37:00Z Indexed on 2012/06/06 10:40 UTC
Read the original article Hit count: 167

Filed under:
|

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,
    ));
}

© Stack Overflow or respective owner

Related posts about php

Related posts about yii