Having a problem getting the elapsed time between two dates. Following examples I have created two datetime objects, verified with a print_r but when I attempt to use date_diff on them I get an error in that the formatted output is simply just that: the format string.
My code:
[code=php]
$last_dose = date_create_from_format(‘Y-m-d h:i a’,”$datetaken 08:15 am”);
$curr_time = new datetime();
echo “last dose: “,print_r($last_dose,true).”<br>”;
echo “curr time: “,print_r($curr_time,true).”<br>”;
$interval = date_diff($last_dose, $curr_time);
echo “elapsed is: “.$interval->format(‘d h:l’);
The output from the two print_r shows exactly what I expect to see, and they show as datetime objects as well. The interval output is just the format string itseld: d h:l.
According to the manual apparently the date_diff and the format functions are only good for :
(PHP 5 >= 5.3.0, PHP 7)
So what do I have to use with my current install?