How To Filter Date Greater Than A Current Date And Less Than Current Date In Yii Gridview Filter

I’m creating an application where I have 2 buttons namely : Past and Present.

For this I’m using Advanced Search form, in which I created buttons Past and Present out of the field called time.




    <?php echo $form->radioButtonList($model,'time',array('Past'=>'Past','Future'=>'Future'),array('onclick' => 'this.form.submit()')); ?>



Now, coming to my question -

By using CJuiDatePicker I created two filters for date which is in datetime format.




    <?php

    $dateisOn = $this->widget('zii.widgets.jui.CJuiDatePicker', array(

                // 'model'=>$model,

                'name' => 'Event[date_first]',

                'language' => 'id',

                'value' => $model->time,

                // additional javascript options for the date picker plugin

                'options' => array(

                    'showAnim' => 'slide',

                    'dateFormat' => 'Y-m-d H:i:s',

                    'changeMonth' => 'true',

                    'changeYear' => 'true',

                    'constrainInput' => 'false',

                ),

                'htmlOptions' => array(

                    'style' => 'height:20px;width:70px;',

                ),

    // DONT FORGET TO ADD TRUE this will create the datepicker return as string

                    ), true) . '<br> To <br> ' . $this->widget('zii.widgets.jui.CJuiDatePicker', array(

                // 'model'=>$model,

                'name' => 'Event[date_last]',

                'language' => 'id',

                'value' => $model->time,

                // additional javascript options for the date picker plugin

                'options' => array(

                    'showAnim' => 'slide',

                    'dateFormat' => 'Y-m-d H:i:s',

                    'changeMonth' => 'true',

                    'changeYear' => 'true',

                    'constrainInput' => 'false',

                ),

                'htmlOptions' => array(

                    'style' => 'height:20px;width:70px',

                ),

    // DONT FORGET TO ADD TRUE this will create the datepicker return as string

                    ), true);

    ?>


  

In GridView I got two filters, one for startdate and enddate. I added the following code in gridview.




    <?php     array(

                'name'=>'time',

                'filter'=>$dateisOn,

                'value'=>'$data->time',

                ),         

    ?>  



Now, my questions are -

  1. How can I get the dates filtered when I click on Past button which is going to filter all the dates less than current date(datetime format).

  2. How can I get the dates filtered when I click on Future button which is going to filter all the dates greater than current date(datetime format).

  3. CJuiDatePicker works on only single click and after that it disappears, the page has to refreshed again to get it back.