I have 2 Datetime Objects and I used diff to get an interval. I then want to add this interval to another date to get a date in the future. Here is my code:
$start = new DateTime($start_date);
$stop = new DateTime($end_date);
$interval = $start->diff($stop);
$now = new DateTime($update_date);
$now->add($interval);
return $now->format('Y-m-d H:i:s');
To verify the numbers were adding up, I did this:
echo "interval = " . $interval->format("%d days, %h hours and %i minutes");
echo "<br/> date = ". $update_date;
echo "<br/> result = ". $now->format('Y-m-d H:i:s');
and I got this:
interval = 0 days, 0 hours and 13 minutes
date = 2016-01-14 21:03:41
result = 2016-01-14 20:50:22
So if Im adding 13 minutes to my date, why is the result 13 minutes less?