Print dates 15 days in advance from a start date

1

I have this code that printed the dates stipulating the beginning and the end between them:

How would I make the system calculate 15 days after the $ dateStart ?

For example:

If the start date was this $ dateStart = 05/11/2018 the system already stipulated the end date by adding the 15 days to get $ dateEnd = 19/11/2018 < strong>

//Star date
    $dateStart      = '05/11/2018';
    $dateStart      = implode('-', array_reverse(explode('/', substr($dateStart, 0, 10)))).substr($dateStart, 10);
    $dateStart      = new DateTime($dateStart);

    //End date
    $dateEnd        = '25/04/2013';
    $dateEnd        = implode('-', array_reverse(explode('/', substr($dateEnd, 0, 10)))).substr($dateEnd, 10);
    $dateEnd        = new DateTime($dateEnd);

    //Prints days according to the interval
    $dateRange = array();
    while($dateStart <= $dateEnd){
        $dateRange[] = $dateStart->format('Y-m-d');
        $dateStart = $dateStart->modify('+1day');
    }
 foreach ($dateRange as $value) {

     echo $value;
 }
    
asked by anonymous 05.11.2018 / 18:05

1 answer

1

With strtotime you can add whatever you want, see example below:

$data = "20-10-2014"; 
echo date('d/m/Y', strtotime("+2 days",strtotime($data)));

This example was taken from another post on the subject: Add days to a date

    
05.11.2018 / 18:09