How are you storing the shifts? Start and End Hours?
fortunately, time is a positively increasing function.
PHP Code:
if($start < '08:00') {
$thirty = (($end <= '08:00') ? strtotime($end) : strtotime('08:00')) - strtotime($start); //Seconds of time.
}
if($end > '08:00') {
$twenty = (($end <= '20:00') ? strtotime($end) : strtotime('20:00')) - (($start >= '08:00') ? strtotime($start) : strtotime('08:00'));
}
if($end > '20:00') {
$thirty += strtotime($end) - (($start >= '20:00') ? strtotime($start) : strtotime('20:00'));
}
someone come along behind me and do it cleaner than this. I know it's possible.
Bookmarks