Hello
I am new in the yii Business, so please be gent
Iam formatting Dates with the following Line and it works very well:
'value'=>'Yii::app()->dateFormatter->format("dd.MM.yyyy",strtotime($data->datum))'
But when the $data->datum ist invalid or empty, it is getting me the todays Date… For me it would be fine if it displays nothing when de Date is empty.
What can i do? Thank you!
patrickm
(Yiiframework)
October 19, 2016, 10:03am
2
Which version of Yii are you using? The documentation says that null values are only checked since 1.1.11:
http://www.yiiframework.com/doc/api/1.1/CDateFormatter#format-detail
patrickm
(Yiiframework)
October 19, 2016, 3:05pm
4
strtotime returns the current date when called without a valid date:
http://php.net/manual/en/function.strtotime.php
Try something along those lines:
'value'=>'$data->datum ? Yii::app()->dateFormatter->format("dd.MM.yyyy",strtotime($data->datum)) : ""'