Adding months to a existing date?

后端 未结 2 1613
情深已故
情深已故 2021-01-23 18:59

I have a date where I need to add months to, but somehow it returns the epoch date

$duration = 28;
$row[\'end_date\'] = \'2010-09-22 0000:00:00\';

$newEndDate =         


        
相关标签:
2条回答
  • 2021-01-23 19:22

    Use this instead:

    $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");
    
    0 讨论(0)
  • 2021-01-23 19:29
    $newEndDate = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
    
    0 讨论(0)
提交回复
热议问题