The title is a bit confusing but what I want to get to is the following with this code:
$hrs=['2021/08/11 08:00:00 AM','2021/08/11 08:00:00 PM'];
$fecha1 = DateTime::createFromFormat('Y/m/d h:i:s A', $hrs[0]);
$fecha2 = DateTime::createFromFormat('Y/m/d h:i:s A', $hrs[1]);
$interval = $fecha1->diff($fecha2);
$divideBy=20;
$minutes= "PT".($interval->h / $divideBy * 60)."M";
$period = new DatePeriod($fecha1, new DateInterval($minutes), $fecha2);
foreach ($period as $dt) {
echo $dt->format("H:i:s \n");
}
which I get a time range
08:00:00
08:36:00
09:12:00
09:48:00
10:24:00
11:00:00
11:36:00
12:12:00
12:48:00
13:24:00
14:00:00
14:36:00
15:12:00
15:48:00
16:24:00
17:00:00
17:36:00
18:12:00
18:48:00
19:24:00
From this range, I want to exclude the break time. For example, if the break time is at 2:00 p.m. , I want to exclude 2:00 p.m. and 2:36 p.m. from that list.