ajsie ajsie - 1 year ago 105
PHP Question

Date minus 1 year?

I've got a date in this format:


How do I return the same date but 1 year earlier?

Answer Source

You can use strtotime:

$date = strtotime('2010-01-01 -1 year');

The strtotime function returns a unix timestamp, to get a formatted string you can use date:

echo date('Y-m-d', $date); // echoes '2009-01-01'