How do I fix this error in PHP: "A non well formed numeric value encountered" [duplicate]
Asked Answered
K

1

8

Possible Duplicate:
A non well formed numeric value encountered

Why doesn't this work?

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

The error I see is:

A non well formed numeric value encountered

Knight answered 14/8, 2012 at 17:56 Comment(2)
I think you should consider the answer given here : https://mcmap.net/q/150960/-a-non-well-formed-numeric-value-encounteredSorayasorb
The link to a possible duplicate isn't valid. Nothing at that link helps me.Knight
A
28

The second parameter of strtotime expects a timestamp, not a string. See the manual on strtotime.

You can use strtotime again on your second parameter to get what you want:

echo gmdate('Y-m-d H:i:s',strtotime('+7 days',strtotime('2035-01-01 00:00:00')));
Abacus answered 14/8, 2012 at 17:59 Comment(1)
Finally, I looked at at least 10 answers to this problem, no one else explained the need to convert it to a timestamp before using strtotime() again.Harvin

© 2022 - 2024 — McMap. All rights reserved.