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

前端 未结 4 508
自闭症患者
自闭症患者 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条回答
  •  Happy的楠姐
    2020-12-01 16:13

    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');
    

提交回复
热议问题