Increase days to php current Date()

前端 未结 11 1343
予麋鹿
予麋鹿 2020-12-04 19:13

How do I add a certain number of days to the current date in PHP?

I already got the current date with:

$today = date(\'y:m:d\');

Ju

11条回答
  •  时光说笑
    2020-12-04 19:37

    With php 5.3

        $date = new DateTime();
        $interval = new DateInterval('P1D');
        echo $date->format('Y-m-d') , PHP_EOL;
        $date->add($interval);
        echo $date->format('Y-m-d'), PHP_EOL;
        $date->add($interval);
        echo $date->format('Y-m-d'), PHP_EOL;
    

    will output

    2012-12-24

    2012-12-25

    2012-12-26

提交回复
热议问题