Search code examples
phpdateunix-timestamp

Get +30 days from timestamp (PHP)


Here is my code:

$graceperiod = strtotime("+30 day","23-12-2013");
echo $graceperiod;

I get the following output:

Sat, 31 Jan 1970 00:00:23 GMT

The year is wrong. Any idea why it is not converting properly?


Solution

  • strtotime is a "dangerous" function if you don't know what it does exactly. You should try it like this

    strtotime('+30 days', $timestamp);
    

    Where $timestamp is an actual timestamp, because it's not as reliable as you may wish