class timespan { private $seconds = 0; private $minutes = 0; private $hours = 0; private $days = 0; /** * timespan constructor. * * @param $seconds */ public function __construct( $seconds ) { $this->calculate( $seconds ); } private function calculate( $input ) { $this->seconds = $input % 60; $this->minutes = (( $input - $this->seconds ) / 60 ) % 60; $this->hours = (((( $input - $this->seconds ) / 60 ) - $this->minutes ) / 60 ) % 24; $this->days = floor ( ((((( $input - $this->seconds ) / 60 ) - $this->minutes ) / 60 ) / 24 ) ); } /** * @return mixed */ public function getSeconds() { return $this->seconds; } /** * @return mixed */ public function getMinutes() { return $this->minutes; } /** * @return mixed */ public function getHours() { return $this->hours; } /** * @return mixed */ public function getDays() { return $this->days; } }