Yii Framework Forum: CGridView date() Problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CGridView date() Problem Rate Topic: -----

#1 User is offline   danielm 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 26-February 10

Posted 26 February 2010 - 01:00 PM

I try to formate my Timestamp:

$this->widget('zii.widgets.grid.CGridView', array(
    'dataProvider'=>$dataProvider,
    'columns'=>array(
		array(          
            'class'=>'CLinkColumn',
			'header'=>'Titel',
			'labelExpression'=>'$data->titel',
			'urlExpression'=>'Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey))',
		),
		/*array(
			'name'=>'Titel',
       		'type'=>'raw',
			'value'=>'CHtml::ajaxLink(CHtml::encode($data->titel), array("inhaltsseite/update", "id"=>$data->primaryKey), array("update" => "#contentContainer"))',
	
		),*/
        'erstelltvonid', 
		array(       
            'name'=>'erstellt',
            'value'=>'date("m.d.y - H:i", $data->erstellt)',
        ),
		array(           
            'class'=>'CButtonColumn',
			'template'=>'{update} {delete}',
        ),
    ),
	'emptyText'=>'Keine Daten vorhanden.',
	'pager'=>array(
		'class'=>'CLinkPager',
	),
	'summaryText'=>'{start}-{end} von {count}',
	'template'=>'{items}<div class="actionBarFooter">{pager} {summary}</div>',
));


but as a result I just get: 01.01.70 - 01:00.

By using date($data->erstellt) // without "m.d.y - H:i" i receive the correct return.

Can anybody help me?
0

#2 User is offline   Daniel M 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 19-January 10
  • Location:Germany, Saarland

Posted 26 February 2010 - 02:06 PM

How exactly do you store dates?
For example, MySQL DateTime format (yyyy-mm-dd hh:mm:ss) or unix timestamps?

If DateTime format, I guess you need to calculate the unix timestamp first. You can do this with CDateTimeParser::parse($var, 'yyyy-MM-dd HH:mm:ss').
Utinam ea res tibi usui fuerit!
0

#3 User is offline   danielm 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 26-February 10

Posted 26 February 2010 - 08:37 PM

Works perfectly! Thanks a ton
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users