I am currently getting the difference between two times in minutes like this below, and it works fine...
$time1 = strtotime($firsttime);
$time2 = strtotime($secondtime);
$interval = abs($time2 - $time1);
$diffinminutes = round($interval / 60);
But say for example...
$firsttime = 02:05
$secondtime = 20:05
This calculation would return 1080 minutes (18 hours x 60 minutes).
I would like to be able to get the shortest difference, based on the time being a connected circle (i.e. like a clock haha).
So in the example above, I would rather it "go backwards" from 02:05 until it hit 20:05 and thus return 360 minutes (6 hours x 60 minutes).
In other words, I'm looking to get the shortest difference, regardless of which direction we go to find it.
Hopefully this makes sense.
Any insight on how to accomplish this would be appreciated, thank you!