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?
knut
(Knut Urdalen)
2
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).
Example:
$ php -r 'echo date("c", null)."\n";'
1970-01-01T01:00:00+01:00
I would say best practice is to check for empty value if there is any chance that this date can be empty.