Hello,
I was trying to get the difference between two date. Unfortunately I only get whole number and not the formatted as required.
Below is my code which does not work as required.
I get request of 2 instead of 02h30m. Kindly advise what is the issue. Thanks.
[php]
$hd1 = new Datetime(‘2016-10-18 08:30:00’);
$hd2 = new Datetime(‘2016-10-18 12:00:00’);
$HoldInterval = $hd2->diff($hd1);
$d1 = new Datetime(‘2016-10-18 09:00:00’);
$d2 = new Datetime(‘2016-10-18 10:00:00’);
$TactInterval = $d2->diff($d1);
//$interval = $TactInterval - $HoldInterval ); // This is not working…
$dt1 = $TactInterval->format(’%Hh%Im’);
$dt2 = $HoldInterval->format(’%Hh%Im’);
echo $dt1."
";
echo $dt2."
";
$dt3 = $dt2 - $dt1; // This is working but only a whole number shows. it show be 02h30m.
//$dt4 = $dt3->format(’%Hh%Im’); // does not work when formated.
echo $dt3."
";
[/php]