Well, since you don't really say how you get this data and where do you want to display the result, here is just how you can get what you want :
function getDateDiff($breakOut, $breakIn) {
$dateStart = new DateTime($breakOut);
$dateEnd = new DateTime($breakIn);
$dateDiff = $dateStart->diff($dateEnd);
return $dateDiff->format("%H:%I:%S");
}
Now you just have to use the function and return the diff :
2 John Doe BREAK OUT 2018-05-24 09:00:41
3 John Doe BREAK IN 2018-05-24 09:10:45
var_dump(getDateDiff("2018-05-24 09:00:41", "2018-05-24 09:10:45")); // '00:10:04'
4 John Doe BREAK OUT 2018-05-24 13:00:49
5 John Doe BREAK IN 2018-05-24 13:30:52
var_dump(getDateDiff("2018-05-24 13:00:49", "2018-05-24 13:30:52")); // '00:30:03'
6 John Doe BREAK OUT 2018-05-24 15:30:56
7 John Doe BREAK IN 2018-05-24 15:40:59
var_dump(getDateDiff("2018-05-24 15:30:56", "2018-05-24 15:40:59")); // '00:10:03'
So if you want to get those result in a PHP loop, maybe you can try this :
// your data array, I assume it looks like this since I have no info
$array(
2 => array(
"name" => "John Doe",
"break" => "2018-05-24 09:00:41",
),
3 => array(
"name" => "John Doe",
"break" => "2018-05-24 09:10:45",
),
4 => array(
"name" => "John Doe",
"break" => "2018-05-24 13:00:49",
),
5 => array(
"name" => "John Doe",
"break" => "2018-05-24 13:30:52",
),
...
);
$array_break_time = array();
foreach ($array as $key => $data) {
if ($key % 2 == 0) {
if(isset($array[$key + 1])) {
$array_break_time[] = getDateDiff($data["break"], $array[$key + 1]["break"])
}
}
}
The output is :
$array_break_time = array(
0 => '00:10:04',
1 => '00:30:03'
....
);
But since I have no more details don't know if it's good in your case !