Get elapsled time

@param int $seconds
@return string
161059
public function getTime($seconds) {

        $dtF = new \DateTime("@0");
        $dtT = new \DateTime("@$seconds");
        return $dtF->diff($dtT)->format('%h hours, %i minutes %s sec.');

    }
656749
def get(self):
        """"""
        elapsed = datetime.now() - self._previous
        self._previous += elapsed
        return elapsed.total_seconds()
767796
public static function getTime($ts = 'now', $format = 'U', $tz = null) {
		if (!Util::isValidTimezone($tz)) {
			$tz = Util::getClientTimezone();
		}
		
		$dt = new DateTime(null, new DateTimeZone($tz));
		(is_int($ts)) ? $dt->setTimestamp($ts) : $dt->modify($ts);

		$time = $dt->format('H') * self::SECONDS_IN_AN_HOUR;
		$time += $dt->format('i') * self::SECONDS_IN_A_MINUTE;
		$time += $dt->format('s');

		return $dt->setTimestamp($time)->format($format);
	}
435511
public function getElapsedTimeInSeconds()
    {
        if(!$this->_timeStartInMicroSeconds)
        {
            return 0;
        }

        $microSecsStart = $this->_timeStartInMicroSeconds;
        $microSecsStop = $this->_timeStopInMicroSeconds;

        if($microSecsStop == 0)
        {
            // The function stopTimer was not called.
            $microSecsStop = microtime(true);
        }

        $seconds = $microSecsStop - $microSecsStart;

        return round($seconds, 4);
    }
955160
public static function prettySeconds( $seconds = 0.0 )
    {
        $_remain = $seconds;
        $_hours = floor( $_remain / Enums\DateTime::SecondsPerHour );
        $_remain -= $_hours * Enums\DateTime::SecondsPerHour;

        $_minutes = floor( $_remain / Enums\DateTime::SecondsPerMinute );
        $_remain -= $_minutes * Enums\DateTime::SecondsPerMinute;

        return $_hours . 'h ' . $_minutes . 'm ' . number_format( $_remain, 2 ) . 's';
    }
401179
public static function duration(int $seconds = null, int $precision = 0) :string {

		// if no timestamp is provided
		if(!$seconds) {
			// there is no conversion to do at all
			return '';
		}
		// list of deltas by period
		$deltas[1] = array(60, Locales::get('minute'));
		$deltas[2] = array(3600, Locales::get('heure'));
		$deltas[3] = array(86400, Locales::get('jour'));
		$deltas[4] = array(604800, Locales::get('semaine'));
		$deltas[5] = array(2592000, Locales::get('mois'));
		$deltas[6] = array(31104000, Locales::get('an'));
		// for very short periods
		$seconds = $seconds < 60 ? Locales::get('quelques instants') : $seconds;
		// for each time period available
		for($i = 6; $i > 0; $i--) {
			// if if we is the largest period available
			if($seconds >= $deltas[$i][0]) {
				// compute the remaining time in the current period's unit
				$duration = round($seconds/$deltas[$i][0], $precision);
				// format the relative date
				$duration = $duration . ' ' . Locales::get(
					// add a trailing plural "s"
					intval($duration) == 1 ? $deltas[$i][1] : rtrim($deltas[$i][1], 's') . 's'
				);
				// break out of the loop
				break;
			}
		}
		// return the duration
		return isset($duration) ? $duration : $seconds;

	}
1304651
public static function toTimeString($time)
    {
        $times = array(
            'hour'   => 3600000,
            'minute' => 60000,
            'second' => 1000
        );

        $ms = $time;

        foreach ($times as $unit => $value) {
            if ($ms >= $value) {
                $time = floor($ms / $value * 100.0) / 100.0;
                return $time . ' ' . ($time == 1 ? $unit : $unit . 's');
            }
        }
        return $ms . ' ms';
    }
673192
public static function convertSecondsToElapsedTime($seconds) {

        // Hours component
        $hours = floor($seconds / 3600);

        // Minutes component
        $remainder = $seconds - ($hours * 3600);
        $minutes = floor($remainder / 60);

        // Seconds component
        $seconds = round($remainder - ($minutes * 60));


        return sprintf("%02d", $hours) . ":" . sprintf("%02d", $minutes) . ":" . sprintf("%02d", $seconds);

    }
150995
public static function unixtimeFormatDay($seconds)
    {
        $time = '';
        if ($seconds >= 86400) {
            $time .= intval($seconds / 86400) . '天';
        }
        if ($seconds % 86400 >= 3600) {
            $time .= intval(($seconds % 86400) / 3600) . '小时';
        }
        if ($seconds % 3600 >= 60) {
            $time .= intval(($seconds % 3600) / 60) . '分钟';
        }
        return $time;
    }
95508
public function seconds($seconds) {

		if(false === ('-' . intval($seconds) == '-' . $seconds)) {
   			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($seconds)), E_USER_ERROR);
   		}

		$this -> seconds = $seconds;

		return $this;
	}
907143
public function getFormattedDuration($seconds)
    {
        $duration = ceil($seconds) . ' seconds';

        if ($duration > 60) {
            $duration = round($duration / 60, 1) . ' minutes';
        } elseif ($duration > 3600) {
            $duration = round($duration / (60 * 60), 1) . ' hours';
        } elseif ($duration > (24 * 60 * 60)) {
            $duration = round($duration / (24 * 60 * 60), 1) . ' days';
        }

        return $duration;
    }
1351100
public static function getOffsetBySeconds($seconds)
    {
        $tmp    = abs($seconds);
        $hour   = (int) ($tmp / 3600);
        $minute = (int) (($tmp % 3600) / 60);

        $result = $seconds < 0 ? '-' : '+';
        $result.= ($hour < 10  ? '0' . $hour   : $hour) . ':';
        $result.= $minute < 10 ? '0' . $minute : $minute;

        return $result;
    }
422642
protected function secondsToString($seconds)
    {
        $seconds = (int) $seconds;

        $time = array();

        // get hours
        $hours = floor($seconds / 3600);
        $time[] = str_pad($hours, 2, '0', STR_PAD_LEFT);

        // get minutes
        $seconds = $seconds % 3600;
        $time[] = str_pad(floor($seconds / 60), 2, '0', STR_PAD_LEFT);

        // get seconds
        $time[] = str_pad($seconds % 60, 2, '0', STR_PAD_LEFT);

        return implode(':', $time);
    }
624468
public function plusSeconds(int $seconds) : Instant
    {
        if ($seconds === 0) {
            return $this;
        }

        return new Instant($this->epochSecond + $seconds, $this->nano);
    }
43694
protected function getHours()
    {
        $intSecondsPerHour = ($this->isPositive()) ? DateTimeSpan::SECONDS_PER_HOUR : ((-1) * DateTimeSpan::SECONDS_PER_HOUR);
        $intHours = floor($this->intSeconds / $intSecondsPerHour);
        if ($this->isNegative()) {
            $intHours = (-1) * $intHours;
        }
        return $intHours;
    }
516329
public function get_recently_active_sessions($seconds=600) {
		if(is_null($seconds) || !is_numeric($seconds)) {
			$seconds = 10;
		}
		$sql = "SELECT session_id, uid, date_created, last_updated, num_checkins
			FROM cswal_session_table WHERE last_updated > NOW() - interval '". $seconds
				." seconds'";
		try {
			$retval = $this->db->run_query($sql);
		}
		catch(Exception $ex) {
			throw new Exception($ex);
		}
		
		return($retval);
	}
739696
public function addSeconds($seconds)
    {
        $seconds = (float) $seconds;
        $interval = new DateInterval('PT' . abs($seconds) . 'S');

        if ($seconds < 0) {
            $interval->invert = 1;
        }

        return $this->add($interval);
    }