php date format YYYY-MM-DD minus or add one week from now?
Use strtotime()
echo date('d-m-Y', strtotime("+1 week")); //1 week in the future
echo date('d-m-Y', strtotime("-1 week")); //1 week ago
You can use the DateTime
class to do calendar calculations. For exaple, to add one week, you could use code like this:
$date = new DateTime('22-05-2011');
$date->modify('+1 week');
strtotime will handle this.
$pDate = strtotime('22-05-2011 + 1 week');
echo date('d-m-Y',$pDate);
Added: This is if you want to start from a specific date. If you just want 'today' +/- a week', mark JohnP's answer as correct. : )