views:

268

answers:

2

Hello,

I have a signup form in my ZF application, that has a dropdown for "Time Zone". I have listed some of its options below for reference

option value="-12:00">International Date Line West /option

option value="-11:00">Midway Island, Samoa /option

option value="-10:00">Hawaii /option

option value="-09:00">Alaska /option

option value="-08:00">Pacific Time (US & Canada) Tijuana /option

option value="-07:00">Arizona /option

The user is suppose to select a Time Zone as per his location and when he logs in I plan to use the "date_default_timezone_set()" function to set the Time Zone as the user selected Time Zone.

How do I convert the selected user TimeZone into a value that ZF can understand and output a date & time as per the User Selected Time Zone.

Thanks

A: 

PHP has a list of timezones that can be used with date_default_timezone_set().

When you set the timezone and create a date with Zend_Date, the timezone is taken into account automatically.

Not sure what your question is, but maybe this will help.

Zend_Date - Working Examples - Time Zones

Richard Nguyen
A: 

After setting default timezone, all standart php functions like date() take it into consideration. So while signup just save user selected timezone, then set it every time user visits your site. No other changes needed. Also note, that date('Z') gives timezone offset in seconds -43200 through 50400 if you need it.

Piotr M.