Adding three months to a date in PHP

前端 未结 9 1110
我寻月下人不归
我寻月下人不归 2020-12-02 13:03

I have a variable called $effectiveDate containing the date 2012-03-26.

I am trying to add three months to this date and have been unsu

9条回答
  •  情深已故
    2020-12-02 13:28

    This answer is not exactly to this question. But I will add this since this question still searchable for how to add/deduct period from date.

    $date = new DateTime('now');
    $date->modify('+3 month'); // or you can use '-90 day' for deduct
    $date = $date->format('Y-m-d h:i:s');
    echo $date;
    

提交回复
热议问题