News:

Wondering if this will always be free?  See why free is better.

Main Menu

Server time and users time offset

Started by qICEp, October 06, 2012, 12:14:51 AM

Previous topic - Next topic

qICEp

I suggest to automatize detecting and configuring server and users timezone and auto sync it...i  know that we need to configure server time and than users need to edit their time offset but why not automatize it on user register?

MrPhil

I know that SMF has tried automating server (default/guest) timezone setting (and may still try it). It was a disaster. The resulting timezone was in a deprecated format (e.g., Etc/GMT+4) and had no Daylight Saving Time/Summer Time setting. If you know how to query the correct timezone name (e.g., America/New_York) from the visitor's browser, I'm sure the developers would like to know. Even better, any visitor (not just signed-on members) would be able to see their own correct time, and not just the default time.

emanuele



Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

qICEp

Quote from: MrPhil on October 06, 2012, 09:03:07 AM
I know that SMF has tried automating server (default/guest) timezone setting (and may still try it). It was a disaster. The resulting timezone was in a deprecated format (e.g., Etc/GMT+4) and had no Daylight Saving Time/Summer Time setting. If you know how to query the correct timezone name (e.g., America/New_York) from the visitor's browser, I'm sure the developers would like to know. Even better, any visitor (not just signed-on members) would be able to see their own correct time, and not just the default time.
It is possible with jQuery.I found these script on internet but its not working perfectly
function get_time_zone_offset( ) {
     var current_date = new Date( );
     var gmt_offset = current_date.getTimezoneOffset( ) / 60;
     return gmt_offset;
}

These one returns that my timezone offset is -2 but actually its +2 (Podgorica Montenegro/ Belgrade serbia)
So with additional code these can be fixed.

MrPhil

For some reason the standard is + to West, - to East. More importantly, does your method tell you Daylight Saving Time (Summer Time) rules? Different countries within a given timezone band have different rules for when DST starts and ends. That was the problem with the old SMF code -- it set the same time offset year-round. Also, knowing only the hours + or - (for part of the year, anyway), doesn't tell you the correct timezone name (e.g., 'America/New_York') to use for the PHP timezone calls. The best SMF could do was Etc/GMT+5 or Etc/GMT+4, depending on when in the year the forum was set up.

青山 素子

Don't forget that not everyone in the same "band" will have the same offset. From an example here in the US:

The state of Arizona is in the "Mountain" time zone. It is offset -0700. All other states in this zone observe DST. Arizona does not.

qICEp, the huge problem is that even trying to detect the offset means you won't know the rules followed, just how far off the user is at that exact moment.

The larger problem would be solved by telling SMF the timezone that the server is using (this should be set in the PHP config but rarely is), and then offering the user a list of timezones. Of course, that list would be quite long, see the list of timezones in the tz database.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


MrPhil

Another timezone list that might be organized better is http://us3.php.net/manual/en/timezones.php. Note that it's organized by region, so, for example, Hawaii is listed under "Pacific" and not "America" (America covers North and South American continents, not just the USA). It's still a bit confusing  for many users, as it only lists one city per timezone/DST rule, and most people still think in terms of "Eastern Standard Time/DST" rather than "America/New_York".

Part of SMF setup should be to ask the owner to pick from a list of timezones (provided they have PHP 5.2+) to set the default (guest) time. Members should be able to pick from this same list when configuring their profiles (no more hours offset). The timezone list should be extended with more familiar entries, such as "EST/EDT" which would translate to a standard such as "America/New_York". If they have PHP 5.1, I suppose that Simple Machines could provide a list of timezones to choose from. For PHP 5.0 and earlier, I don't know what would be best -- perhaps keep the current hours offset, or translate the selected timezone name to some hour offset. The latter way, when the host finally upgrades to PHP 5.1+, everything will work properly without any intervention by the forum owner or members (no need to manually change hour offsets to timezone names).

I haven't heard of any browsers that provide the correct timezone name. That would be nice, as guests would then see the correct time for them.

青山 素子

Quote from: MrPhil on October 11, 2012, 08:51:13 AM
Another timezone list that might be organized better is http://us3.php.net/manual/en/timezones.php. Note that it's organized by region, so, for example, Hawaii is listed under "Pacific" and not "America" (America covers North and South American continents, not just the USA). It's still a bit confusing  for many users, as it only lists one city per timezone/DST rule, and most people still think in terms of "Eastern Standard Time/DST" rather than "America/New_York".

That's still using the tz database. If you look toward the bottom of the list I linked, you'll see that it provides aliased names such as "America/Pacific" and "America/Central" for those familiar with those names. It also provides for such things as "America/Arizona" to handle that exception.

Quote from: MrPhil on October 11, 2012, 08:51:13 AM
I haven't heard of any browsers that provide the correct timezone name. That would be nice, as guests would then see the correct time for them.

No browser does this that I am aware. The best you can get is an offset, which is what it used to put in a default offset suggestion for the current SMF mechanism.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Arantor

The problem with providing that full list, even organised, is that it's simply way too big.

It caused some minor debate when I took the bull by the horns and provided a list for users to select from in Wedge, much like how phpBB and XenForo solve it - you provide a much condensed list where you join timezones together that have common rules, requires minor maintenance occasionally, at the cost of being way more meaningful for users.

Presenting a list of a few hundred items to users might be programmatically elegant, but it certainly is not user friendly. I'm not overly happy at presenting a list of 75 items, to be honest, but it's more elegant than about 400.

QuoteNo browser does this that I am aware. The best you can get is an offset, which is what it used to put in a default offset suggestion for the current SMF mechanism.

It doesn't even do that on registration, I might add. (I did try this, it's not bad, but using the timezone is better.)

What I would also note is that you could try something through geolocation or inferring the timezone from other things if you have them (e.g. Windows asking you what keyboard or language, it is reasonable that someone using English/British would probably be in the main UK timezone band)

青山 素子

Quote from: Arantor on October 11, 2012, 11:09:07 AM
The problem with providing that full list, even organised, is that it's simply way too big.

Agreed.


Quote from: Arantor on October 11, 2012, 11:09:07 AM
It caused some minor debate when I took the bull by the horns and provided a list for users to select from in Wedge, much like how phpBB and XenForo solve it - you provide a much condensed list where you join timezones together that have common rules, requires minor maintenance occasionally, at the cost of being way more meaningful for users.

A condensed list would be useful. In some cases, there are timezones already set up for that, such as Australia/NSW and US/Eastern. The fun part comes when you add in places like Africa, where timezones seems to be really messed up. I'm not sure how complex regions are handled in those simplified lists.


Quote from: Arantor on October 11, 2012, 11:09:07 AM
Presenting a list of a few hundred items to users might be programmatically elegant, but it certainly is not user friendly. I'm not overly happy at presenting a list of 75 items, to be honest, but it's more elegant than about 400.

Breaking down by region in a two-step process might be more useful, and certainly would make it easier to handle than just dumping all the entries in a single list.

Quote from: Arantor on October 11, 2012, 11:09:07 AM
What I would also note is that you could try something through geolocation or inferring the timezone from other things if you have them (e.g. Windows asking you what keyboard or language, it is reasonable that someone using English/British would probably be in the main UK timezone band)

Useful, but you'll likely still have a high rate of false positives. Using the information as a best-guess when presenting a suggestion to the user would be an acceptable use.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Arantor

QuoteA condensed list would be useful. In some cases, there are timezones already set up for that, such as Australia/NSW and US/Eastern. The fun part comes when you add in places like Africa, where timezones seems to be really messed up. I'm not sure how complex regions are handled in those simplified lists.

You don't do it quite by region, you do it by groups of time zone rules. Go through the registration page on Wedge.org, or XenForo or phpBB and you'll see generally how this works.

QuoteBreaking down by region in a two-step process might be more useful, and certainly would make it easier to handle than just dumping all the entries in a single list.

Maybe. Maybe not.

Quote
Useful, but you'll likely still have a high rate of false positives. Using the information as a best-guess when presenting a suggestion to the user would be an acceptable use.

Yup, you couldn't really use it as anything more than a best guess.

MrPhil

If the full list of timezones is too overwhelming for most people, how about a utility to click on a map (where they are)? At each click, you can drill down to a more detailed (zoomed in) map, or say "this is it". Users near timezone boundaries might have to zoom in further to make sure they're on the right side of the line. From that map you would get the proper timezone name.

It would be a great timesaver if you could use something like Google Maps to get a lat/lon, but I don't know if there is anything to map that to the timezone names. If ever the timezone database changes and a name is rejected by PHP as invalid, SMF would have to repeat the process (it could always be kicked off manually, too).

青山 素子

Quote from: MrPhil on October 11, 2012, 04:26:13 PM
If the full list of timezones is too overwhelming for most people, how about a utility to click on a map (where they are)? At each click, you can drill down to a more detailed (zoomed in) map, or say "this is it". Users near timezone boundaries might have to zoom in further to make sure they're on the right side of the line. From that map you would get the proper timezone name.

It would be a great timesaver if you could use something like Google Maps to get a lat/lon, but I don't know if there is anything to map that to the timezone names. If ever the timezone database changes and a name is rejected by PHP as invalid, SMF would have to repeat the process (it could always be kicked off manually, too).

That's kinda how Anaconda (the installer used by RedHat and derivatives) does it:
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


MrPhil

Nice, but the map should show timezone boundaries and all major cities. The whole point is to make sure you're picking a point within the correct timezone (UTC offset and DST rules). That's not necessarily the nearest to you major city.

Frankly, if someone can't pick their correct timezone from a list (by common name [US EST/EDT] or by major city [America/New_York]), they probably shouldn't be allowed to handle sharp objects. Offering several levels of list (drill down through continent, country, timezones) to make the list more manageable (less overwhelming) would not be a bad thing.

Pick your correct timezone:
[ North America  *  [ Canada            ]
[ South America     [ United States * [ Eastern Time (with DST), New York ]
[ Europe                [ Mexico               [ Central Time (with DST), Chicago     ]
[ Asia                     [ Belize                [ Mountain Time (with DST), Denver   ]
[ Oceania               [ Guatemala        [ Mountain Standard Time, Arizona     ]
[ Africa                     ....                      [ Pacific Time (with DST), Los Angeles ]
[ Australia               ]                            ....
[ Antartica               ]

etc. A place like Hawaii could show up in both NA/USA list and the "proper" Pacific (Oceania) list, because few people are going to look for it under "Pacific". The biggest problem with such a custom list is that it will have to be manually maintained/updated whenever the official list changes. That might be supplied from SMF, or left to the forum owner (don't forget to offer it in different languages!). Internally, it would pick an official name like America/New_York and feed that to PHP's date and time functions. I don't think it would be worth it to have a fallback hour offset in case the list is changed and the previously selected timezone goes out of favor. Just demand that a [new] selection be made from the list.

Advertisement: