diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 6d2dd8f..d65621b 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -1871,7 +1871,9 @@ function drupal_handle_request($test_only = FALSE) {
  * Returns the time zone of the current user.
  */
 function drupal_get_user_timezone() {
-  global $user;
+  if (($container = \Drupal::getContainer()) && $container->has('current_user')) {
+    $user = $container->get('current_user');
+  }
   $config = \Drupal::config('system.date');
 
   if ($user && $config->get('timezone.user.configurable') && $user->isAuthenticated() && $user->getTimezone()) {
