【发布时间】:2019-09-07 10:50:16
【问题描述】:
我正在设置一个表格,我需要从表格发送之日起的下一个星期日,我在我的mealPrepSend.php 文件中有这个作为我的代码:
$deliveryDate = new DateTime();
$deliveryDate->modify('next sunday');
$deliveryDate->format('D d M H:i:s');
表单现在出现错误:
Recoverable fatal error: Object of class DateTime could not be converted to string in /deli/mealPrepSend.php on line 34
我做了一些阅读,发现它与输出的格式有关,非常欢迎任何帮助!
非常感谢,
【问题讨论】:
-
第 34 行是哪一行?这甚至是指您上面显示的三个之一吗?
-
我不确定您的错误来自哪里?您提供的代码应该可以正常工作,因为它可以很好地转换为字符串。以下以您请求的格式返回一个字符串:
$deliveryDate = (new \DateTime('next sunday'))->format('D d M H:i:s');