CGridView create_time formatting 'value'=>'date("M j, Y", $data->creat
Posted 28 July 2012 - 08:10 AM
The formatting code for this is right out of http://www.yiiframew...i/1.1/CGridView
For now, to remove the time stamp I used substr. But with this, I cannot format the date. Here's my code (the commented out data expression is what is not working:
array('header' => 'date',
'value' => 'substr($data->create_time,0,10)'), //'date("M j, Y", $data->create_time)'),
Any ideas? Is this working for anyone else?
Posted 29 July 2012 - 12:05 AM
'value' => 'MyModel::model()->displayDate($data->create_time)',
*Edit - I just tested this and whatever problem I had has gone away.
Posted 30 July 2012 - 12:08 AM
I don't get it. You say create_time is a timestamp? Like a Unix one: '1343392756', or a date: '2012-07-29'?
Its a timestamp. If its a regular date, you must use strtotime():
date("M j, Y", strtotime($data->create_time))
Posted 30 July 2012 - 10:28 AM