1

I'm trying to override the site's timezone in settings.local.php.

Looking at the config file, this should be simple:

$ more system.date.yml
country:
  default: ''
first_day: 0
timezone:
  default: UTC
  user:
    configurable: true
    warn: false
    default: 0

but I've trying various combinations of this and none of them work:

$config['system.date']['timezone']['default'] = 'Europe/London';
$config['system.date.timezone.default'] = 'Europe/London';

1 Answer 1

2

The first example ($config['system.date']['timezone']['default'] = 'Europe/London';) is the correct way to override config values in your settings.php file.

It sounds like you've hit an issue noted in the config override system docs:

Note that values overridden via $config within settings.php will not be viewable from the Drupal administration interface (until #2408549: There is no indication on configuration forms if there are overridden values is fixed, until then you can use Configuration Override Warn or Config Override Inspector) or from inspection via drush (unless you add the --include-overridden flag). The administration interface displays the values stored in configuration so that you can stage changes to other environments that don't have the overrides.

So if you view /admin/config/regional/settings page or the drush cget system.date timezone.default command, it won't show the overridden value.

You can try something like drush cget --include-overridden system.date timezone.default or drush eval 'print \Drupal::config("system.date")->get("timezone.default");' to confirm your overridden value is actually being set in your settings.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.