【问题标题】:How do I fix this error in PHP: "A non well formed numeric value encountered" [duplicate]如何在 PHP 中修复此错误:“遇到格式不正确的数值”[重复]
【发布时间】:2012-08-11 01:58:25
【问题描述】:

可能重复:
A non well formed numeric value encountered

为什么这不起作用?

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

我看到的错误是:

遇到格式不正确的数值

【问题讨论】:

标签: php strtotime


【解决方案1】:

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

您可以在第二个参数上再次使用strtotime 来获得您想要的:

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

【讨论】:

  • 最后,我看了至少10个这个问题的答案,没有人解释需要在再次使用strtotime()之前将其转换为时间戳。
猜你喜欢
  • 2017-09-13
  • 2021-01-08
  • 1970-01-01
  • 1970-01-01
  • 2019-11-17
  • 1970-01-01
  • 2021-08-31
  • 1970-01-01
  • 2013-05-27
相关资源
最近更新 更多