public static function fromString($time): Time
    {
        if (empty($time)) {
            throw new \InvalidArgumentException('Invalid time "".');
        }

        try {
            $date = new \DateTime($time);
        } catch (\Exception $e) {
            throw new \InvalidArgumentException(\sprintf('Invalid time "%s".', $time), 0, $e);
        }

        $return = static::fromDate($date);
        if (\strpos($time, '24') === 0) {
            $return->setHours(24);
        }

        return $return;
    }
public static function fromString($time): Time
    {
        if (empty($time)) {
            throw new \InvalidArgumentException('Invalid time "".');
        }

        try {
            $date = new \DateTime($time);
        } catch (\Exception $e) {
            throw new \InvalidArgumentException(\sprintf('Invalid time "%s".', $time), 0, $e);
        }

        $return = static::fromDate($date);
        if (\strpos($time, '24') === 0) {
            $return->setHours(24);
        }

        return $return;
    }
public static function fromString ( $ time ) : Time { if ( empty ( $ time ) ) { throw new \ InvalidArgumentException ( 'Invalid time "".' ) ; } try { $ date = new \ DateTime ( $ time ) ; } catch ( \ Exception $ e ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Invalid time "%s".' , $ time ) , 0 , $ e ) ; } $ return = static :: fromDate ( $ date ) ; if ( \ strpos ( $ time , '24' ) === 0 ) { $ return -> setHours ( 24 ) ; } return $ return ; }
Create a new time from a string.

@param string $time The time as a string.
@return Time
@throws \InvalidArgumentException If the passed time is invalid.
Create a new time from a string .