I have 4 time values:
$times = array('16:04:12', '16:57:54', '17:59:59', '18:00:00');
I would like to divide the 24 hour time to 2 hour intervals so I will have 12 hours, like: 0:00:01-1:59:59, 2:00:00-3:59:59, 4:00:00-5:59:59, etc.
What I want to do is place these values into those intervals. So the final result should be:
$result = array(
'16:00:00-17:59:59' => array('16:04:12', '16:57:54', '17:59:59'),
'18:00:00-19:59:59' => array('18:00:00')
);
I have tried to create an array with the intervals and then loop through it checking if one is bigger than the other, but it did not work as intended.
How is it possible to put the hours into these 2 hour intervals?