Skip to content

Instantly share code, notes, and snippets.

@aklump
Created July 2, 2025 15:05
Show Gist options
  • Save aklump/b1747606ddbedde66b1d4096fb7d6512 to your computer and use it in GitHub Desktop.
Save aklump/b1747606ddbedde66b1d4096fb7d6512 to your computer and use it in GitHub Desktop.
Get timezone name per current user.
<?php
if (!$account instanceof \Drupal\Core\Session\AccountInterface || $account->isAnonymous()) {
$timezone_name = \Drupal::config('system.date')->get('timezone.default');
}
else {
$timezone_name = $account->getTimeZone();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment