Jump to content
Larry Ullman's Book Forums

Recommended Posts

I was wondering, what would be the best method for having users select their timezone? Obviously you cannot do a drop down list with each timezone such as "America/New_York" as there would be HUNDREDS of options for them to scrolls through.

I just got my copy of the book today and reading through it I couldn't find a method for having users select their timezone. I noticed on # Script 17.5 - read.php, it shows how to convert timezones, however it doesn't show how users can select their timezone.

 

Wanted to add this which I've seen around:

 

EDIT 1:
http://pellepim.bitbucket.org/jstz/

 

JavaScript that automatically detects timezones. I'm pretty sure that major websites that display times correctly without a user registering or setting a timezone use something similar to this. I just don't know how to use it with PHP/MySQL.

 

 

EDIT 2:

If not using automatic detection, the best way to display the timezones to people would be through your standard drop-down select box with GMT +12 through GMT -12. However I wouldn't know what to assign the values. Could you do this.

<select name="timezone">
	<option name="America/New_York">(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima</option>
</select>

The only problem is, will every location in the Eastern Standard Timezone have the same time as New York City? The whole Daylight Savings Time throws a huge wrench in the gears on this issue...

EDIT 3:
Checked current time in New York (5:27 PM) and Bogota (4:27 PM). Daylight Savings Time does mess it up,

Link to comment
Share on other sites

For automatic selection, you'd have to use JavaScript. There's no other way to get the selection from the browser. I would use that to create a default timezone and then provide a drop down menu for them to override it. 

Link to comment
Share on other sites

 Share

×
×
  • Create New...