Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By kim.pepper on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.8.x
Introduced in version:
8.8.0-alpha1
Issue links:
Description:
The function drupal_get_user_timezone()
in bootstrap.inc has been replaced with an event listener which updates the default timezone based on site and user configuration. You can now call the builtin PHP function date_default_timezone_get()
.
The default time zone is set on the following events:
- A request via KernelEvents::REQUEST
- When time zone config changes, via ConfigCrudEvent
- When a user is set via a new AccountSetEvent
The TimeZoneResolver handles these events and uses the same fall back logic:
- Use the user-specified timezone, or if not set
- Use the site default configured timezone, or if not set
- Use the system default timezone
Before:
$timezone = drupal_get_user_timezone()
After:
$timezone = date_default_timezone_get();
Impacts:
Module developers
Comments
So I just got stabbed by this
So I just got stabbed by this. Can someone please explain if there is a reason why cron (e.g.hook_cron()
) calls use the fall back (system or 'UTC') and not the configured setting in Drupal?Edit: sorry, my bad. Was testing this in drush, not the actual cron.