You are here

function system_time_zones in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/system.module \system_time_zones()

Generate an array of time zones and their local time&date.

Parameters

$blank: If evaluates true, prepend an empty time zone option to the array.

8 calls to system_time_zones()
Date::buildOptionsForm in core/modules/views/src/Plugin/views/field/Date.php
Default options form that provides the label widget that all fields should have.
DateTimeFormatterBase::settingsForm in core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php
Returns a form to configure settings for the formatter.
RegionalForm::buildForm in core/modules/system/src/Form/RegionalForm.php
Form constructor.
SiteConfigureForm::buildForm in core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php
Form constructor.
system_user_timezone in core/modules/system/system.module
Add the time zone field to the user edit and register forms.

... See full list

File

core/modules/system/system.module, line 1308
Configuration system that lets administrators modify the workings of the site.

Code

function system_time_zones($blank = NULL) {
  $zonelist = timezone_identifiers_list();
  $zones = $blank ? array(
    '' => t('- None selected -'),
  ) : array();
  foreach ($zonelist as $zone) {

    // Because many time zones exist in PHP only for backward compatibility
    // reasons and should not be used, the list is filtered by a regular
    // expression.
    if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) {
      $zones[$zone] = t('@zone', array(
        '@zone' => t(str_replace('_', ' ', $zone)),
      ));
    }
  }

  // Sort the translated time zones alphabetically.
  asort($zones);
  return $zones;
}