PHP date strtotime not working

user979331 picture user979331 · Apr 12, 2012 · Viewed 15.3k times · Source

I wrote this piece of code

echo date("Y-m-d", strtotime($date, strtotime("+ " . $days . " days")));

$date = 2012-04-12
$days = 15

I am looking to add $days (15 days) to the date (2012-04-12) I am expecting to get 2012-04-27 and this code returns me 2012-04-12, what am I doing wrong?

Answer

Nate picture Nate · Apr 12, 2012
echo date('Y-m-d', strtotime('+15 days', strtotime('2012-04-12')));