Adding three months to a date in PHP

前端 未结 9 1143
我寻月下人不归
我寻月下人不归 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:38

    Tchoupi's answer can be made a tad less verbose by concatenating the argument for strtotime() as follows:

    $effectiveDate = date('Y-m-d', strtotime($effectiveDate . "+3 months") );
    

    (This relies on magic implementation details, but you can always go have a look at them if you're rightly mistrustful.)

提交回复
热议问题