Hey guys, I have a problem:
I’m trying to format the time I show in the list as AM/PM time. So, in my database I store time as DATETIME.
The values that are stored in the database are 2012-01-01 00:00:00. When the client is created the DATETIME is NULL.
But when I try to display it in CGridview I need to use strtotime. The problem is that strtotime defaults NULL value to a random time instead of not displaying anything.
My question is, is there a way around it? Maybe some kind of Yii function I’m missing?
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'customer_id',
'dataProvider'=>$model->search_waiting(),
'filter'=>$model,
'enablePagination'=>true,
'updateSelector'=>".updatebutton",
'cssFile'=> Yii::app()->request->baseUrl . "/css/grid-view.css",
'htmlOptions'=>array('data-enhance'=>'false',),
'pager'=>array('cssFile'=>Yii::app()->request->baseUrl . '/css/pager.css', 'header' => "",
"prevPageLabel" => "Prev", "nextPageLabel" => "Next"),
'columns'=>array( 'party_name',
'phone',
array(
'name'=>'wait_time',
'value'=>'date("h:i A", [u]strtotime($data->wait_time)[/u])',),
array(
'name'=>'final_time',
'value'=>'date("h:i A", [u]strtotime($data->final_time)[/u])',),
'groupsize',
array(
'class'=>'CButtonColumn',
'template'=>'{update}',
'updateButtonUrl'=>'Yii::app()->controller->createUrl("/client/waiting-update",array("id"=>$data->customer_id))',
'updateButtonImageUrl'=>Yii::app()->request->baseUrl . '/images/update.png',
'updateButtonOptions'=>array("rel"=>"external"),
),
),
));
?>