public static function fromString(string $time, string $tz = null): self
    {
        try {
            if (!isset($tz)) {
                $tz = date_default_timezone_get();
            }
            return new static(
                new \DateTimeImmutable($time, self::_createTimeZone($tz)));
        } catch (\Exception $e) {
            throw new \RuntimeException(
                "Failed to create DateTime: " .
                self::_getLastDateTimeImmutableErrorsStr(), 0, $e);
        }
    }
public static function fromString(string $time, string $tz = null): self
    {
        try {
            if (!isset($tz)) {
                $tz = date_default_timezone_get();
            }
            return new static(
                new \DateTimeImmutable($time, self::_createTimeZone($tz)));
        } catch (\Exception $e) {
            throw new \RuntimeException(
                "Failed to create DateTime: " .
                self::_getLastDateTimeImmutableErrorsStr(), 0, $e);
        }
    }
public static function fromString ( string $ time , string $ tz = null ) : self { try { if ( ! isset ( $ tz ) ) { $ tz = date_default_timezone_get ( ) ; } return new static ( new \ DateTimeImmutable ( $ time , self :: _createTimeZone ( $ tz ) ) ) ; } catch ( \ Exception $ e ) { throw new \ RuntimeException ( "Failed to create DateTime: " . self :: _getLastDateTimeImmutableErrorsStr ( ) , 0 , $ e ) ; } }
Initialize from datetime string.

@link http://php.net/manual/en/datetime.formats.php
@param string $time Time string
@param string|null $tz Timezone, if null use default.
@throws \RuntimeException
@return self
Initialize from datetime string .