PHP strtotime returns a 1970 date when date column is null

后端 未结 4 2016
我在风中等你
我在风中等你 2020-12-03 15:04

I want to display $row->depositdate in dd-mm-yyyy format.

If the date column in database is null the date displayed is : 01-01-1970

         


        
4条回答
  •  -上瘾入骨i
    2020-12-03 15:38

    NULL is interpreted as 0 by strtotime, since it want to be passed an integer timestamp. A timestamp of 0 means 1-1-1970.

    So you'll have to check for yourself if $row->depositdate === NULL, and if so, don't call strtotime at all.

提交回复
热议问题