Increase days to php current Date()

前端 未结 11 1293
予麋鹿
予麋鹿 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:42

    php supports c style date functions. You can add or substract date-periods with English-language style phrases via the strtotime function. examples...

    $Today=date('y:m:d');
    
    // add 3 days to date
    $NewDate=Date('y:m:d', strtotime('+3 days'));
    
    // subtract 3 days from date
    $NewDate=Date('y:m:d', strtotime('-3 days'));
    
    // PHP returns last sunday's date
    $NewDate=Date('y:m:d', strtotime('Last Sunday'));
    
    // One week from last sunday
    $NewDate=Date('y:m:d', strtotime('+7 days Last Sunday'));
    

    or

    
                            
        
    提交评论

提交回复
热议问题