I have a DateTime date:
$entrada = new \DateTime($request->get('entrada'));
I need to get another date of the same type added n days.
I have a DateTime date:
$entrada = new \DateTime($request->get('entrada'));
I need to get another date of the same type added n days.
You can use DateInterval
to add the number of days you need. Here is an example:
$fecha = new \DateTime('2018-12-07');
$agregarDias = 10;
$fecha->add(new \DateInterval("P{$agregarDias}D"));
echo $fecha->format('Y-m-d'); // 2018-12-17
The link to the official documentation is: link
I hope the following code will help you
$fechauno='2018-09-27';
$fecha = strtotime(date($fechauno));
$start=$fecha;
while (date ("$date",$start)>+1)
{
$start-=86400;
}
//for para obtener la segunda fecha
for ($i=7; $i <8; $i++)
{
//aquí se hace la suma de N días para obtener el resultado que se desea obtener
$fechados=date("Y-m-d",$start+ ($i*86400));?><br><?php
}