timestamp = $dt->format('U'); $adj = ($this->timestamp - ($this->timeToSeconds($conf['startTime']))); //align shift start change to midnight. $this->daysSince = floor($adj / 86400); //Whole days since EPOCH $this->cyclesSince = floor(($this->daysSince / 3)*10)/10; //Cycles since EPOCH $this->cyclePart = floor(((($this->cyclesSince - floor($this->cyclesSince)) * 10) / count($conf['shifts']))); //Day in cycle $this->currentShift = $conf['shifts'][$this->cyclePart]; //Current Shift } private function timeToSeconds($time){ // returns 24-hour time into seconds since midnight $hm1 = explode(':', $time); // split hours and minutes $hm2 = $hm1[0] + round($hm1[1] / 60, 2); // determine number of hours since midnight $hm3 = $hm2 * 3600; // convert hours to seconds return $hm3; } } ?>