src/View/Helper/FormHelper.php
public function timeZoneSelect($field, array $options = [])
    {
        $regions = [
            'Europe' => DateTimeZone::EUROPE,
            'America' => DateTimeZone::AMERICA,
            'Africa' => DateTimeZone::AFRICA,
            'Antarctica' => DateTimeZone::ANTARCTICA,
            'Asia' => DateTimeZone::ASIA,
            'Atlantic' => DateTimeZone::ATLANTIC,
            'Indian' => DateTimeZone::INDIAN,
            'Pacific' => DateTimeZone::PACIFIC
        ];
        $timezones = [];
        foreach ($regions as $name => $mask) {
            $zones = DateTimeZone::listIdentifiers($mask);
            foreach ($zones as $timezone) {
                // Lets sample the time there right now
                $time = new DateTime(null, new DateTimeZone($timezone));
                // Us dumb Americans can't handle millitary time
                // Remove region name and add a sample time
                $timezones[$name][] = [
                    'value' => $timezone,
                    'text' => 'UTC ' . $time->format('P') . ' ' . substr($timezone, strlen($name) + 1)
                ];
            }
        }
        $options['options'] = $timezones;
        return $this->input($field, $options);
    }
public function timeZoneSelect($field, array $options = [])
    {
        $regions = [
            'Europe' => DateTimeZone::EUROPE,
            'America' => DateTimeZone::AMERICA,
            'Africa' => DateTimeZone::AFRICA,
            'Antarctica' => DateTimeZone::ANTARCTICA,
            'Asia' => DateTimeZone::ASIA,
            'Atlantic' => DateTimeZone::ATLANTIC,
            'Indian' => DateTimeZone::INDIAN,
            'Pacific' => DateTimeZone::PACIFIC
        ];
        $timezones = [];
        foreach ($regions as $name => $mask) {
            $zones = DateTimeZone::listIdentifiers($mask);
            foreach ($zones as $timezone) {
                // Lets sample the time there right now
                $time = new DateTime(null, new DateTimeZone($timezone));
                // Us dumb Americans can't handle millitary time
                // Remove region name and add a sample time
                $timezones[$name][] = [
                    'value' => $timezone,
                    'text' => 'UTC ' . $time->format('P') . ' ' . substr($timezone, strlen($name) + 1)
                ];
            }
        }
        $options['options'] = $timezones;
        return $this->input($field, $options);
    }
public function timeZoneSelect ( $ field , array $ options = [ ] ) { $ regions = [ 'Europe' => DateTimeZone :: EUROPE , 'America' => DateTimeZone :: AMERICA , 'Africa' => DateTimeZone :: AFRICA , 'Antarctica' => DateTimeZone :: ANTARCTICA , 'Asia' => DateTimeZone :: ASIA , 'Atlantic' => DateTimeZone :: ATLANTIC , 'Indian' => DateTimeZone :: INDIAN , 'Pacific' => DateTimeZone :: PACIFIC ] ; $ timezones = [ ] ; foreach ( $ regions as $ name => $ mask ) { $ zones = DateTimeZone :: listIdentifiers ( $ mask ) ; foreach ( $ zones as $ timezone ) { // Lets sample the time there right now $ time = new DateTime ( null , new DateTimeZone ( $ timezone ) ) ; // Us dumb Americans can't handle millitary time // Remove region name and add a sample time $ timezones [ $ name ] [ ] = [ 'value' => $ timezone , 'text' => 'UTC ' . $ time -> format ( 'P' ) . ' ' . substr ( $ timezone , strlen ( $ name ) + 1 ) ] ; } } $ options [ 'options' ] = $ timezones ; return $ this -> input ( $ field , $ options ) ; }
Render a grouped time zone select box.

@param string $field The input field name.
@param array $options Additional options for the generated select.
@return string
Render a grouped time zone select box .