I'm having a (small) issue regarding a time calculator in PHP. The problem is the following:
I have four dates (all on the same day) but different hours. There is a group A and a group B which is like:
GROUP A:
from 9:00 till 12:00
GROUP B:
from 10:30 till 12:30
What I need is a way to check if group b falls in group a (which it does for 2 hours), and if it falls in group a then it has to calculate for how many hours it does. After that it has to add the remaining hours that were not overlapsing (which is 12:00 till 12:30 so 30 minutes)
.
So the answer of this calculation should be 2.5 hours
, because group B
was in group A
for 2 hours
and then it had a half hour (0.5) out of group A
.
I hope that someone can help me with this because I have no idea how to calculate this in PHP.