How can I get a date after 15 days/1 month in PHP?

后端 未结 6 1097
醉梦人生
醉梦人生 2021-02-01 18:35

In my PHP code I have a date in my variable \"$postedDate\".
Now I want to get the date after 7 days, 15 days, one month and 2 months have elapsed.

Which date functi

6条回答
  •  粉色の甜心
    2021-02-01 19:11

    try this

    $date = date("Y-m-d");// current date
    
    $date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
    $date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
    $date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
    $date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
    $date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");
    

提交回复
热议问题