晦涩de咚 2016-01-14 09:43:03 4373次浏览 0条评论 0 0 0

controller:转化将时间转化为时间戳

if(isset($_GET['CompanyVouchers'])){
	$_GET['CompanyVouchers']['giveTime']=isset($_GET['CompanyVouchers']['giveTime'])?strtotime($_GET['CompanyVouchers']['giveTime']):'';
	$model->attributes=$_GET['CompanyVouchers'];
}

model:增加查询区间

$criteria->compare('giveTime',">=".($this->giveTime));
$criteria->compare('giveTime',"<".((int)$this->giveTime+86400));

view:时间戳转化为时间

 <?php  
 $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'company-vouchers-grid',
        'dataProvider'=>$model->search($id),
        'filter'=>$model,
        'afterAjaxUpdate' => 'reinstallDatePicker',
        'columns'=>array(
			 array('name' => 'giveTime','value'=>'$data->giveTime!=0?date("Y-m-d H:i:s","$data->giveTime"):" "', 'type' => 'raw', 'filter'=>$this->widget('zii.widgets.jui.CJuiDatePicker', array('model'=>$model, 'attribute'=>'giveTime', 'htmlOptions' => array('id' => 'datepicker_for_due_date','value'=>isset($model->giveTime) ? $model->giveTime!=null?date('Y-m-d',$model->giveTime): '' : '',), 'options' => array('dateFormat' =>
							'yy-mm-dd')), true)),
),
));
Yii::app()->clientScript->registerScript('re-install-date-picker', "
    function reinstallDatePicker(id, data) {
        $('#datepicker_for_due_date').datepicker
();
    }
");
?>
    没有找到数据。
您需要登录后才可以评论。登录 | 立即注册