C Formatter return today

Hello

I am new in the yii Business, so please be gent :D

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!

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

I am using 1.1.16

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)) : ""'



Thank you!