Reputation: 1606
I am trying to add 28 days to a date and keep getting the following error:
Message: A non well formed numeric value encountered
My code is:
$expirationDate = 1396885780;
$entryDate = 1396885780;
if ($expirationDate) {
$expiration = time(strtotime($expirationDate, '+28 day'));
} else {
$expiration = time(strtotime($entryDate, '+28 day'));
}
So basically I am passing a %U format date (which I think is universal) and wanting to add 28 days to it.
Can anyone see the issue here?
Upvotes: 0
Views: 339
Reputation: 212462
Argument 2 when calling strtotime()
The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in now, or the current time if now is not supplied.
And then there is no need to call time() to try and convert that to a timestamp, because strtotime() returns a timestamp already
$expirationDate = 1396885780;
$entryDate = 1396885780;
if ($expirationDate) {
$expiration = strtotime('+28 day', $expirationDate);
} else {
$expiration = strtotime('+28 day', $entryDate);
}
Upvotes: 1