Add days to a date in PHP

前端 未结 7 1832
情深已故
情深已故 2020-12-15 08:42

Is there any php function available where I can add days to a date to make up another date? For example, I have a date in the following format: 27-December-2011

If I

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 09:14

    $date = new DateTime('27-December-2011');
    $date->add(new DateInterval('P7D'));
    echo $date->format('d-F-Y') . "\n";
    

    Change the format string to be whatever you want. (See the documentation for date()).

提交回复
热议问题