Ihave two variable format time
example :
$start = 16:00:00
$end = 20:00:00
expected results = 04:00
how to find the difference
Ihave two variable format time
example :
$start = 16:00:00
$end = 20:00:00
expected results = 04:00
how to find the difference
Try this
<?php
$dteStart = new DateTime("16:00:00");
$dteEnd = new DateTime("20:00:00");
$dteDiff = $dteStart->diff($dteEnd);
print $dteDiff->format("%H:%I"); // if you want to print seconds then use this: "%H:%I:%S" in format function
?>
Very Simple Solution :
$start = '16:00:00';
$end = '20:00:00';
$start = date("g:i", strtotime($start));
$end = date("g:i", strtotime($end));
echo $start;// Print $start Variable
echo $end; // Print $end Variable