The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> Web Design Help
|
How do YOU handle time zones and DST on your website?
Discuss How do YOU handle time zones and DST on your website? in the Web Design Help forum on Dev Shed. How do YOU handle time zones and DST on your website? Web Design Help forum discussing topics such as video editing, audio editing, animation, etc. This is also the place to get recommendations on preferred web authoring tools.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 9th, 2011, 11:02 PM
|
|
|
|
How do YOU handle time zones and DST on your website?
'Evening gents and gals,
I was wondering what creative solutions some have come up with for handling time zones and DST internationally? I have a couple ideas, but all have their pitfalls:
Option 1:
Have user select a unix style timezone (America/Chicago, America/Anchorage etc)
Benefits: if servers are kept up to date, this should keep track of whatever DST and timezone standard is current
Pitfall: Huge list of time zones for users to scroll through
Option 2:
Have user select standard time zone name (Mountain, Eastern) and check an "Honor DST Rules" checkbox
Benefit:Only ~28 time zones to scroll through
Pitfall:Have to keep an up to date list of when/if DST applies for each region, and run a check/calculation for each user or each page render
Option 3:
Fire an ajax request off to a page that updates the offset (obtained from the browser) every time a user logs in.
Benefit:Modern browsers should follow whatever the system time is set to, and thus should be (for the most part) current.
Pitfall: Complete reliance on javascript is silly, and an extra request/database query
Obviously, there are a few others out there, such as combining 1 and 2
My best example for something that does this extremely well:
Facebook.
That website only announces a users birthday when it's that users birthday in that users time zone (AFAIK) - you never see birthday wishes at 10pm or 9pm the previous day. Yet, I don't remember ever entering a time zone, which makes me think it uses the third option I listed.
|

November 9th, 2011, 11:54 PM
|
 |
Lost in code
|
|
|
|
|
You might try #3 on top of #2 or #1, but I wouldn't do it exclusively. A user may intentionally have their clock set incorrectly, so you should give them a way to work around that (or maybe they're traveling and the time changes automatically on their phone but they don't want it to change on your website).
#1 is probably your best list. Most people know what major cities they live near. A significant number of people have no idea what time zone they live in or whether or not daylight savings time is active.
Even if you haven't told Facebook where you live I can almost guarantee you that they have a pretty good idea already.
|

November 10th, 2011, 02:23 AM
|
|
|
|
Yeah I never thought of people not knowing their timezone, but you're right, it's probably a larger amount than most would feel comfortable admitting.
Thanks for the suggestions, I probably will go with option 1 + 3 - just have to think of a good way to break it down. Perhaps a country selector? Maybe I could have that automagically populate based on IP.
Dunno how I'd combat time zone updates with method 3 in the situation you suggested. Perhaps turn them off if a mobile browser is detected?
I'll brainstorm a bit haha. Thanks
|

November 10th, 2011, 10:48 AM
|
 |
CSS & JS/DOM Adept
|
|
Join Date: Jul 2004
Location: USA
|
|
I use option2 with this list of timezones. Users that haven't selected a timezone will see times in the default that I set.
Code:
$timezones = array(
'-0100' => '(GMT -1:00 hour) Azores, Cape Verde Islands',
'-0200' => '(GMT -2:00) Mid-Atlantic',
'-0300' => '(GMT -3:00) Brazil, Buenos Aires, Georgetown',
'-0330' => '(GMT -3:30) Newfoundland',
'-0400' => '(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz',
'-0500' => '(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima',
'-0600' => '(GMT -6:00) Central Time (US & Canada), Mexico City',
'-0700' => '(GMT -7:00) Mountain Time (US & Canada)',
'-0800' => '(GMT -8:00) Pacific Time (US & Canada)',
'-0900' => '(GMT -9:00) Alaska',
'-1000' => '(GMT -10:00) Hawaii',
'-1100' => '(GMT -11:00) Midway Island, Samoa',
'-1200' => '(GMT -12:00) Eniwetok, Kwajalein',
'+0000' => '(GMT) Western Europe Time, London, Lisbon, Casablanca',
'+0100' => '(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris',
'+0200' => '(GMT +2:00) Kaliningrad, South Africa',
'+0300' => '(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg',
'+0330' => '(GMT +3:30) Tehran',
'+0400' => '(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi',
'+0430' => '(GMT +4:30) Kabul',
'+0500' => '(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent',
'+0530' => '(GMT +5:30) Bombay, Calcutta, Madras, New Delhi, Colombo',
'+0600' => '(GMT +6:00) Almaty, Dhaka, Bangladesh',
'+0700' => '(GMT +7:00) Bangkok, Hanoi, Jakarta',
'+0800' => '(GMT +8:00) Beijing, Perth, Singapore, Hong Kong',
'+0900' => '(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk',
'+0930' => '(GMT +9:30) Adelaide, Darwin',
'+1000' => '(GMT +10:00) Eastern Australia, Guam, Vladivostok',
'+1100' => '(GMT +11:00) Magadan, Solomon Islands, New Caledonia',
'+1200' => '(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka'
);
Quote: | Have to keep an up to date list of when/if DST applies for each region |
I don't do that though. I rely on the server to know if DST is active or not.
Quote: | run a check/calculation for each user or each page render |
Don't you have to do that anyway for any of the ways to allow users to see times in their own timezone?
Quote: | Huge list of time zones for users to scroll through |
Yeah. Displaying that large list as a single level would be a mistake, but if there was a good way for users to filter through it, then it might be best.
|

November 10th, 2011, 01:03 PM
|
|
|
Kravvitz, that's very similar to the list I'm using now haha. Infact, I think it's exactly the same - except I use seconds for the offset.
Quote: | I don't do that though. I rely on the server to know if DST is active or not. |
How does your server know it's DST for their timezone? Do you pass a guestimated area to it? The issue being that DST begins at different times and different direction depending on which country you live.
I thought about trying to match up a unix style time zone with the offset they provide. IE if they pick GMT -7:00, the server stores it as 'America/North Dakota/Beulah and I can just cue it off with a set_default_timezone() in php. Whereas if they pick -7:00 with no DST, I can set it to 'America/Phoenix'. This will CATO once a city/state changes their DST standards, since I have no interest in following DST standards religiously.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|