Adding days to $Date in PHP

前端 未结 9 2143
时光取名叫无心
时光取名叫无心 2020-11-22 09:32

I have a date returned as part of a mySQL query in the form 2010-09-17

I would like to set the variables $Date2 to $Date5 as follows:

$Dat

9条回答
  •  醉话见心
    2020-11-22 10:15

    Here is the simplest solution to your query

    $date=date_create("2013-03-15"); // or your date string
    date_add($date,date_interval_create_from_date_string("40 days"));// add number of days 
    echo date_format($date,"Y-m-d"); //set date format of the result
    

提交回复
热议问题