public static function checkTimezoneDefault(string $timezoneAllowed, bool $errOnMisMatch = false) : bool
    {
        $time_default = new \DateTime();
        $tz_default = $time_default->getTimezone()->getName();
        if (
            ($timezoneAllowed == 'UTC' || $timezoneAllowed == 'Z')
            && ($tz_default == 'UTC' || $tz_default == 'Z')
        ) {
            return true;
        }
        if ($tz_default != $timezoneAllowed) {
            if ($errOnMisMatch) {
                throw new \LogicException(
                    'Default timezone[' . $tz_default. '] doesn\'t match allowed timezone[' . $timezoneAllowed
                    . '], date.timezone '
                    . (!ini_get('date.timezone') ? 'not set in php.ini.' :
                        'of php.ini is \'' . ini_get('date.timezone') . '\'.'
                    )
                );
            }
            return false;
        }
        return true;
    }
public static function checkTimezoneDefault(string $timezoneAllowed, bool $errOnMisMatch = false) : bool
    {
        $time_default = new \DateTime();
        $tz_default = $time_default->getTimezone()->getName();
        if (
            ($timezoneAllowed == 'UTC' || $timezoneAllowed == 'Z')
            && ($tz_default == 'UTC' || $tz_default == 'Z')
        ) {
            return true;
        }
        if ($tz_default != $timezoneAllowed) {
            if ($errOnMisMatch) {
                throw new \LogicException(
                    'Default timezone[' . $tz_default. '] doesn\'t match allowed timezone[' . $timezoneAllowed
                    . '], date.timezone '
                    . (!ini_get('date.timezone') ? 'not set in php.ini.' :
                        'of php.ini is \'' . ini_get('date.timezone') . '\'.'
                    )
                );
            }
            return false;
        }
        return true;
    }
public static function checkTimezoneDefault ( string $ timezoneAllowed , bool $ errOnMisMatch = false ) : bool { $ time_default = new \ DateTime ( ) ; $ tz_default = $ time_default -> getTimezone ( ) -> getName ( ) ; if ( ( $ timezoneAllowed == 'UTC' || $ timezoneAllowed == 'Z' ) && ( $ tz_default == 'UTC' || $ tz_default == 'Z' ) ) { return true ; } if ( $ tz_default != $ timezoneAllowed ) { if ( $ errOnMisMatch ) { throw new \ LogicException ( 'Default timezone[' . $ tz_default . '] doesn\'t match allowed timezone[' . $ timezoneAllowed . '], date.timezone ' . ( ! ini_get ( 'date.timezone' ) ? 'not set in php.ini.' : 'of php.ini is \'' . ini_get ( 'date.timezone' ) . '\'.' ) ) ; } return false ; } return true ; }
Check that default timezone is equivalent of arg timezoneAllowed.

Call to ensure that local default timezone is set, and accords with what
is expected.

Does NOT rely on (use) the internally memorized local (default) timezone
object which get established first time the Time constructor gets called.
@see Time::$timezoneLocal

@param string $timezoneAllowed
Examples: 'UTC', 'Z', 'Europe/Copenhagen'.
UTC and Z are considered the same.
@param bool $errOnMisMatch
True: throws exception on timezone mismatch.

@return bool

@throws \LogicException
If mismatch and arg errOnMisMatch; logic exception because
considered a configuration error.
Check that default timezone is equivalent of arg timezoneAllowed .