如何在 PHP 中修复此错误:“遇到格式不正确的数值”


How do I fix this error in PHP: "A non well formed numeric value encountered"

可能的重复项:
遇到格式不正确的数值

为什么这不起作用?

echo gmdate('Y-m-d H:i:s',strtotime('+7 days','2035-01-01 00:00:00'));

我看到的错误是:

遇到格式不正确的数值

strtotime的第二个参数需要一个时间戳,而不是一个字符串。请参阅手册 strtotime .

您可以在第二个参数上再次使用 strtotime 来获取所需的内容:

echo gmdate('Y-m-d H:i:s',strtotime('+7 days',strtotime('2035-01-01 00:00:00')));