$date + 1 year?

Matt picture Matt · Dec 15, 2009 · Viewed 205k times · Source

I'm trying to get a date that is one year from the date I specify.

My code looks like this:

$futureDate=date('Y-m-d', strtotime('+one year', $startDate));

It's returning the wrong date. Any ideas why?

Answer

Misho picture Misho · Jan 25, 2013
$futureDate=date('Y-m-d', strtotime('+1 year'));

$futureDate is one year from now!

$futureDate=date('Y-m-d', strtotime('+1 year', strtotime($startDate)) );

$futureDate is one year from $startDate!