php - Filter Date using Date Picker in Yii -


i have generated crud screens using gii.. have search form, have put date picker, give user select date wants.

but problem have date stored in seconds in database.

and know can convert date using strtotime. how filter using search method in model?

this date picker

<?php          $this->widget('zii.widgets.jui.cjuidatepicker', array(          'name'=>'ordering_date',         'id'=>'ordering_date',         // additional javascript options date picker plugin         'options'=>array(             'showanim'=>'fold',         ),         'htmloptions'=>array(             'style'=>'height:20px;'         ),         ));     ?> 

and search method in model. want compare ordering_date

public function search() {     // warning: please modify following code remove attributes     // should not 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,     )); } 

try this:

$this->widget('zii.widgets.jui.cjuidatepicker', array(         'model'=>$model,         'attribute'=>'ordering_date',         'options'   => array('dateformat' => 'mm-dd-yy',), 

and search

$begindate = cdatetimeparser::parse($this->ordering_date, 'mm-dd-yyyy'); $enddate   = $begindate + 24* 60*60; $criteria->addbetweencondition('ordering_date', $begindate, $enddate); 

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -