I have two variables (which i'm getting from database):
$start = '07:14:10';
$end = '07:14:58';
I need to get the difference between these.
I think the answer could be 00:00:48
.
I have two variables (which i'm getting from database):
$start = '07:14:10';
$end = '07:14:58';
I need to get the difference between these.
I think the answer could be 00:00:48
.
Using Datetime::diff this could be done.
$datetime1 = new DateTime('07:14:10');
$datetime2 = new DateTime('07:14:58');
$interval = $datetime1->diff($datetime2);
Here $interval will be the object in the form
DateInterval Object (
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 48
[invert] => 0
[days] => 0
)
And can find out all the values