我已经尝试使用date_diff和date_create来获得与已经转换为字符串的两个日期的区别.
这里是代码:
$date_1 = date_create(); $date_now = date_format($date_1,'Y-m-d'); //echo $date_now . "\n"; $date=date_create($date_now); date_add($date,date_interval_create_from_date_string("3 days")); $date_return = date_format($date,"Y-m-d"); $diff = date_diff(date_create($date_now),date_create($date_return)); echo $diff;
我收到这个错误:
Object of class DateInterval could not be converted to string