private static function _createDateTime($time = null, $tz = null): \DateTimeImmutable
    {
        if (!isset($time)) {
            $time = 'now';
        }
        if (!isset($tz)) {
            $tz = date_default_timezone_get();
        }
        try {
            $dt = new \DateTimeImmutable($time, self::_createTimeZone($tz));
            return self::_roundDownFractionalSeconds($dt);
        } catch (\Exception $e) {
            throw new \RuntimeException(
                "Failed to create DateTime: " .
                     self::_getLastDateTimeImmutableErrorsStr(), 0, $e);
        }
    }
private static function _createDateTime($time = null, $tz = null): \DateTimeImmutable
    {
        if (!isset($time)) {
            $time = 'now';
        }
        if (!isset($tz)) {
            $tz = date_default_timezone_get();
        }
        try {
            $dt = new \DateTimeImmutable($time, self::_createTimeZone($tz));
            return self::_roundDownFractionalSeconds($dt);
        } catch (\Exception $e) {
            throw new \RuntimeException(
                "Failed to create DateTime: " .
                     self::_getLastDateTimeImmutableErrorsStr(), 0, $e);
        }
    }
private static function _createDateTime ( $ time = null , $ tz = null ) : \ DateTimeImmutable { if ( ! isset ( $ time ) ) { $ time = 'now' ; } if ( ! isset ( $ tz ) ) { $ tz = date_default_timezone_get ( ) ; } try { $ dt = new \ DateTimeImmutable ( $ time , self :: _createTimeZone ( $ tz ) ) ; return self :: _roundDownFractionalSeconds ( $ dt ) ; } catch ( \ Exception $ e ) { throw new \ RuntimeException ( "Failed to create DateTime: " . self :: _getLastDateTimeImmutableErrorsStr ( ) , 0 , $ e ) ; } }
Create DateTime object from time string and timezone.

@param string|null $time Time string, default to 'now'
@param string|null $tz Timezone, default if omitted
@throws \RuntimeException
@return \DateTimeImmutable
Create DateTime object from time string and timezone .