【发布时间】:2014-08-07 12:51:38
【问题描述】:
有很多关于date_diff PHP 函数的问题。但我的似乎有点不同,因为我得到了一个相当不寻常的结果。以下是我的代码:
$today = date( 'd-m-Y', strtotime( "now" ) );
$selectDay = date( 'd-m-Y', strtotime( $row->BOOKING_DATE ));
$interval = date_diff( $selectDay, $today );
我得到的结果:
Warning: date_diff() expects parameter 1 to be DateTime, string given in...
如您所见,$today 和 $selectDay 都是日期。有什么建议? 注意:我有 PHP 5.3 版
【问题讨论】:
-
它期望类
DateTimephp.net/manual/en/class.datetime.php -
date函数返回字符串。date_diff需要两个DateTimes。