我根据主题收到此错误,错误来自下面的代码。
任何人都可以告诉它有什么问题吗?使用 PHP 5.3不是太多的编码员,并希望得到任何帮助。谢谢。它试图比较日期。
请参阅以下代码:
$delivrance_diff = (int)date_diff(date_create($_SESSION['passport_date2'].'-'.month_to_mm($_SESSION['passport_date1']).'-'.$_SESSION['passport_date']), date_create('today'))->format("%r%a");
$expiry_diff = (int)date_diff(date_create('today'), date_create($_SESSION['passport_exp2'].'-'.month_to_mm($_SESSION['passport_exp1']).'-'.$_SESSION['passport_exp']))->format("%r%a");
$exp_diff = (int)date_diff(date_create($_SESSION['passport_date2'].'-'.month_to_mm($_SESSION['passport_date1']).'-'.$_SESSION['passport_date']), date_create($_SESSION['passport_exp2'].'-'.month_to_mm($_SESSION['passport_exp1']).'-'.$_SESSION['passport_exp']))->format("%r%a");
您的一个 date_create(( 没有返回有效的 DateTime 对象,可能是因为输入错误,它的 年-月-日。 因此date_diff不返回要格式化的日期时间对象。