示例#1
0
/**
 * Render select timezone widget
 *
 * @param string $name Name of the select box
 * @param float $value Timezone value. If NULL GMT will be selected
 * @param array $attributes Array of additional attributes
 * @return string
 */
function select_timezone_widget($name, $value = null, $attributes = null)
{
    $selected_value = (double) $value;
    $all_timezones = Timezones::getTimezones();
    $options = array();
    foreach ($all_timezones as $timezone) {
        $option_attributes = $selected_value == $timezone ? array('selected' => true) : null;
        $option_text = $timezone > 0 ? lang("timezone gmt +{$timezone}") : lang("timezone gmt {$timezone}");
        $options[] = option_tag($option_text, $timezone, $option_attributes);
    }
    // if
    return select_box($name, $options, $attributes);
}