Parse the YouTube timestamp to seconds
@param  string $time YouTube format timestamp
@return integer      Seconds
432265
public static function _convert_time($time)
    {
        $reference = new DateTimeImmutable;
        $endTime = $reference->add(new DateInterval($time));

        return $endTime->getTimestamp() - $reference->getTimestamp();
    }
675497
private function parseTime($time) {
		$multipel = 1;

		// Hours
		if (strpos($time, "h") > 0)
			$multipel = 3600;

		// Days
		if (strpos($time, "d") > 0)
			$multipel = 86400;

		// Months
		if (strpos($time, "m") > 0)
			$multipel = 2592000;

		// Trim string
		return intval($time) * $multipel;
	}
37478
public function offsetDatetime($time = null, $offset = 0)
    {
        if ($this->timeFormat === static::$timeFormatDatetime) {
            return date('Y-m-d H:i:s', strtotime(($offset >= 0 ? "+$offset" : $offset) . " seconds", is_string($time) ? strtotime($time) : (is_int($time) ? $time : time())));
        }
        if ($this->timeFormat === static::$timeFormatTimestamp) {
            return (is_int($time) ? $time : time()) + $offset;
        }
        return null;
    }
1068298
protected function timeToIso8601Duration($time)
    {
        $units = array(
            "Y" => 365*24*3600,
            "D" =>     24*3600,
            "H" =>        3600,
            "M" =>          60,
            "S" =>           1,
        );
        
        $str = "P";
        $istime = false;
        
        foreach ($units as $unitName => &$unit) {
            $quot  = intval($time / $unit);
            $time -= $quot * $unit;
            $unit  = $quot;
            if ($unit > 0) {
                if (!$istime && in_array($unitName, array("H", "M", "S"))) { // There may be a better way to do this
                    $str .= "T";
                    $istime = true;
                }
                $str .= strval($unit) . $unitName;
            }
        }
        
        return $str;
    }
294420
public static function getReadableTime($time)
    {
        if ($time < 1000) {
            return "{$time}ms";
        }

        $prefix = '';
        if ($time >= 60000) {
            $prefix = floor($time / 60000) . 'm ';
            $time = $time % 60000;
        }

        return $prefix . number_format((float) ($time / 1000), 3, '.', '') . 's';
    }
44124
private function duration($time){
        if(is_numeric($time)){ 
            return $time;
        }//if
        return (new \DateTime($time))->getTimestamp() - (new \DateTime('now'))->getTimestamp();
    }
1356582
public static function secondsSinceMidnightStr($time)
    {
        $time_a = explode(':', $time);

        switch (count($time_a)) {
            case 0:
            case 1:
                return null;

            case 2:
                // Add seconds
                $time_a[] = 0;
                break;

            case 3:
                break;

            default:
                return null;
        }

        return self::secondsSinceMidnight((int) $time_a[0], (int) $time_a[1], (int) $time_a[2]);
    }
704449
private static function secondsToDuration($seconds)
    {
        $seconds = intval($seconds);
        $hours = floor($seconds / 3600);
        $minutes = floor(($seconds / 60) % 60);
        $seconds = $seconds % 60;

        return "${hours}h ${minutes}m {$seconds}s";
    }
418793
private function formatTimestampFromApi(array $timestamp)
    {
        $timestamp += [
            'seconds' => 0,
            'nanos' => 0
        ];

        $dt = $this->createDateTimeFromSeconds($timestamp['seconds']);

        return $this->formatTimeAsString($dt, $timestamp['nanos']);
    }
147813
protected function internalToFrontend($time)
    {
        $time = $this->tidyInternal($time);
        if (!$time) {
            return null;
        }
        $fromFormatter = $this->getInternalFormatter();
        $toFormatter = $this->getFrontendFormatter();
        $timestamp = $fromFormatter->parse($time);
        if ($timestamp === false) {
            return null;
        }
        return $toFormatter->format($timestamp);
    }
1279939
public static function parseFromLocale($time, $locale, $tz = null)
    {
        return static::rawParse(static::translateTimeString($time, $locale, 'en'), $tz);
    }
370305
public function time($time, $precision = 0)
    {
        $units = 's';
        if ($time < 1e-6) {    // <1us
            $units = 'ns';
            $time *= 1e9;

        } elseif ($time < 1e-3) { // <1ms
            $units = "\xc2\xb5s";
            $time *= 1e6;

        } elseif ($time < 1) { // <1s
            $units = 'ms';
            $time *= 1e3;
        }

        return \round($time, $precision) . ' ' . $units;
    }
714735
protected function formatTimestamp(?int $time = null): string
    {
        if (empty($time)) {
            $time = time();
        }
        return gmdate('Y-m-d H:iO', $time);
    }
853081
protected function exceededTimeParser($time)
    {
        $tomorrow = Carbon::parse($time)->addMinutes(config('laravel2step.laravel2stepExceededCountdownMinutes'))->format('l, F jS Y h:i:sa');
        $remaining = $time->addMinutes(config('laravel2step.laravel2stepExceededCountdownMinutes'))->diffForHumans(null, true);

        $data = [
            'tomorrow'  => $tomorrow,
            'remaining' => $remaining,
        ];

        return collect($data);
    }
1030227
static function parse_microtime( $microtime ){
		list($usec, $sec) = explode( ' ', $microtime ); 
		$ms1 = (float) $usec * 1000;
		$ms2 = (float) $sec  * 1000;
		return $ms1 + $ms2;
	}
623209
public function dateString(string $time): string
    {
        return date($this->dateFormat, ctype_digit($time) ? $time : strtotime($time));
    }
76981
protected function formatTime($time)
    {
        if ($time > 100) {
            $time /= 60;
            if ($time > 100) {
                $time /= 60;

                return number_format($time) . " hr";
            }

            return number_format($time) . " min";
        }

        return number_format($time) . " sec";
    }