我想以dd-mm-yyyy格式显示$ row-> depositdate.
I want to display $row->depositdate in dd-mm-yyyy format.
如果数据库中的日期列为空,则显示的日期为: 01-01-1970
If the date column in database is null the date displayed is : 01-01-1970
echo "<td align=center>".date('d-m-Y', strtotime($row->depositdate))."</td>";如果数据库中的日期为null,则不应显示任何内容,否则应以dd-mm-yyyy格式显示日期.
If the date is null in database it should display nothing , otherwise the date in dd-mm-yyyy format should be displayed.
预先感谢
Sandeep
推荐答案NULL被strtotime解释为0,因为它希望传递一个整数时间戳.时间戳为0表示1-1-1970.
NULL is interpreted as 0 by strtotime, since it want to be passed an integer timestamp. A timestamp of 0 means 1-1-1970.
因此,您必须检查自己是否为$row->depositdate === NULL,如果是,则根本不要调用strtotime.
So you'll have to check for yourself if $row->depositdate === NULL, and if so, don't call strtotime at all.
更多推荐
当日期列为null时,PHP strtotime返回1970年的日期
发布评论