I have this $date variable.
$date = DateTime::createFromFormat('D, d M Y H:i:s', $dates[1][0]);
My question is how to have a $future
date in the same format as the $date
but add 5 minutes to it?
I have this $date variable.
$date = DateTime::createFromFormat('D, d M Y H:i:s', $dates[1][0]);
My question is how to have a $future
date in the same format as the $date
but add 5 minutes to it?
Refrence: Adding minutes to date time in PHP
$minutes_to_add = 5;
$time = new DateTime('2011-11-17 05:05');
$time->add(new DateInterval('PT' . $minutes_to_add . 'M'));
$stamp = $time->format('Y-m-d H:i');
Without Variable:
$time = new DateTime('2011-11-17 05:05');
$time->add(new DateInterval('PT' . '5' . 'M'));
$stamp = $time->format('Y-m-d H:i');
echo $stamp;
That should works :
$format = 'D, d M Y H:i:s';
$future = DateTime::createFromFormat($format, $dates[1][0]);
$future->add(new DateInterval('P5M'));
echo $future->format($format) . "\n";