Hi Thomas, 
I was looking at the API doc for Zend_Date or Zend_Locale to find something
that would return for instance America/Los_Angeles. Any pointer is much
appreciated.
Danke!!
Peter

thomasW wrote:
> 
> You can use Zend_Date or Zend_Locale for this purpose.
> But it is also not problematic to realize this manually.
> 
> Greetings
> Thomas Weidner, I18N Team Leader, Zend Framework
> http://www.thomasweidner.com
> 
> ----- Original Message ----- 
> From: "Peter Wansch" <[email protected]>
> To: <[email protected]>
> Sent: Thursday, April 30, 2009 5:18 PM
> Subject: [fw-general] Getting the timezone from the browser's offset
> 
> 
>>
>> Hi,
>> In our application, we let users select Timezones. To render a timezone 
>> list
>> we use the following view helper which works great:
>>
>> class Ggv_View_Helper_TimezonesList extends Zend_View_Helper_Abstract
>> {
>>    public function timezonesList($selectedzone, $label, $name = 
>> 'timezone',
>> $desc = '')
>>    {
>>        //$output = '<div class="label"><label for="' . $name .
>> '">'.$label.':</label></div>';
>>        $output = '<div class="input"><select name="' . $name . '">';
>>        $output .= $this->timezonechoice($selectedzone);
>>        $output .= '</select>';
>>        $output .= ' '.$desc.' </div>';
>>        return $output;
>>    }
>>
>>    protected function timezonechoice($selectedzone)
>>    {
>>        $all = timezone_identifiers_list();
>>
>>        $i = 0;
>>        foreach($all as $zone)
>>        {
>>            $zone = explode('/', $zone);
>>            $zones[$i]['continent'] = isset($zone[0]) ? $zone[0] : '';
>>            $zones[$i]['city'] = isset($zone[1]) ? $zone[1] : '';
>>            $zones[$i]['subcity'] = isset($zone[2]) ? $zone[2] : '';
>>            $i++;
>>        }
>>
>>        asort($zones);
>>        $structure = '';
>>        foreach($zones as $zone)
>>        {
>>            extract($zone);
>>            if($continent == 'Africa' || $continent == 'America' ||
>> $continent == 'Antarctica' || $continent == 'Arctic' || $continent == 
>> 'Asia'
>> || $continent == 'Atlantic' || $continent == 'Australia' || $continent ==
>> 'Europe' || $continent == 'Indian' || $continent == 'Pacific')
>>            {
>>                if(!isset($selectcontinent))
>>                {
>>                    $structure .= '<optgroup label="' . $continent . '">';
>> // continent
>>                }
>>                elseif($selectcontinent != $continent)
>>                {
>>                    $structure .= '</optgroup><optgroup label="' .
>> $continent . '">'; // continent
>>                }
>>
>>                if(isset($city) != '')
>>                {
>>                    if (!empty($subcity) != '')
>>                    {
>>                        $city = $city . '/' . $subcity;
>>                    }
>>                    $structure .= "<option " . ((($continent . '/' .
>> $city)
>> == $selectedzone) ? 'selected="selected "' : '')." value=\"" .
>> ($continent 
>> .
>> '/' . $city) . "\">" . str_replace('_', ' ', $city) . "</option>"; //
>> timezone
>>                }
>>                else
>>                {
>>                    if (!empty($subcity) != '')
>>                    {
>>                        $city = $city . '/'. $subcity;
>>                    }
>>                    $structure .= "<option " . (($continent ==
>> $selectedzone) ? 'selected="selected "' : '') . " value=\"" . $continent
>> .
>> "\">" . $continent . "</option>"; // timezone
>>                }
>>
>>                $selectcontinent = $continent;
>>            }
>>        }
>>        $structure .= '</optgroup>';
>>        return $structure;
>>    }
>> }
>>
>>
>> In the phtml view script we use the following which also works nicely:
>>
>> <dt><label for="user_join_communityTimeZone"><?= 
>> $this->translate('Community
>> Time Zone:') ?></label></dt>
>>
>>
>> In our controller, we set the user_join_communityTimezZone to:
>>
>> date_default_timezone_get());
>>
>> so the default is the system timezone.
>>
>> Is there an (easy way) without figuring out myself from the offset header 
>> to
>> detect the most likely user timezone to avoid user error?
>> -- 
>> View this message in context: 
>> http://www.nabble.com/Getting-the-timezone-from-the-browser%27s-offset-tp23269606p23269606.html
>> Sent from the Zend Framework mailing list archive at Nabble.com. 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Getting-the-timezone-from-the-browser%27s-offset-tp23269606p23328538.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to