function system_time_zones

Same name in other branches
  1. 9 core/modules/system/system.module \system_time_zones()
  2. 8.9.x core/modules/system/system.module \system_time_zones()
  3. 10 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.

5 calls to system_time_zones()
system_regional_settings in modules/system/system.admin.inc
Form builder; Configure the site regional settings.
system_update_7013 in modules/system/system.install
Convert default time zone offset to default time zone name.
system_user_timezone in modules/system/system.module
Add the time zone field to the user edit and register forms.
user_update_7002 in modules/user/user.install
Convert user time zones from time zone offsets to time zone names.
_install_configure_form in includes/install.core.inc
Form constructor for a site configuration form.

File

modules/system/system.module, line 3412

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: @date', array(
                '@zone' => t(str_replace('_', ' ', $zone)),
                '@date' => format_date(REQUEST_TIME, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone),
            ));
        }
    }
    // Sort the translated time zones alphabetically.
    asort($zones);
    return $zones;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.