CDateFormatter with null datetime

Hi everybody!

I want use CdateFormatter to show date in some table

All is good, but when field is null 01.01.1970 is displaied

[b][i]<td><?php echo Yii::app()->dateFormatter->format('dd.MM.yyyy',$it['sdt']); ?></td>[/i][/b]

Should I do NULL checking by myself or it is a bug?

This is a default behavior in PHP itself.

If you provide NULL to any date/time function in PHP you normally get back the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).


$ php -r 'echo date("c", null)."\n";'


I would say best practice is to check for empty value if there is any chance that this date can be empty.