php date format YYYY-MM-DD minus or add one week from now?

前端 未结 4 530
自闭症患者
自闭症患者 2020-12-01 15:54
today 22-05-2011 so it should be 29-05-2011? ( plus 1 week ) 
or
today 22-05-2011 so it should be 15-05-2011? ( minus 1 week ) 

thanks for looking

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 16:25

    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. : )

提交回复
热议问题