Add value of a variable to a date

0

I am trying to add the value contained in a variable to a date, and that the result is another date.

$hoy = $now->format('d/m/Y');
$dias = 36;

$ newDate would be the result of adding to today's date the days that the variable contains. I have found ways to do it but with a fixed number not with variables, that is to say this:

$now->add(new \DateInterval('P36D'));

But it does not work for me.

    
asked by miaweb 25.04.2018 в 15:59
source

1 answer

0

I understand that this is what you want

$Date = date('Y-m-d');
$dias = 3;
echo date('Y-m-d', strtotime($Date. ' +'.$dias.' days'));

I hope it serves you Greetings.

    
answered by 25.04.2018 в 16:18