View Full Version : Automatic Timezone Setting Correction
I have eliminated the only strange error I could find with this, so I am moving it to full releases.
What This Does
If your users pay as little attention to their options as mine do, this might be just what you need. It uses a JavaScript to detect when a user has their timezone setting set different than their computer's clock. If the computer time does not match, the user is given a JavaScript prompt on your main page asking whether he/she would like to adjust their timezone setting. If they select yes, a new window will pop up, make the change, and close. EXCEPTION: This will yield very unsatisfactory results for users in strange timezones whose offsets are not whole numbers (i.e. Newfoundland is GMT-3.5). I haven't figured out how to do this yet, but I will update this hack if I do figure it out. You may want to just remove those options from your registration/profile options.
Scroll down for screenshots.
Let me know how it works out, and, as always, click INSTALL if you use it, please!
Enjoy!
Download: here (https://vborg.vbsupport.ru/attachment.php?s=&postid=375212)
<i>Reserved for miscellaneous announcements and stuff.</i>
Smoothie
03-29-2003, 06:47 AM
Just re-installed, seems to be working fine! Question, after getting the first prompt, clicking ok, the second alert box appears, but there is a small window which appears in the upper left corner of my screen... why is that?
Glad to hear it. It's the window that the update script runs in. :)
Smoothie
03-29-2003, 07:22 AM
In IE, the window is so tiny, you can't see what it says. In Mozilla, the javascript window covers it up.
Al7zen
03-29-2003, 08:02 AM
Great Work ;)
Smoothie
03-29-2003, 08:29 AM
Found a bug, or a problem. If your time setting in your User CP is set to anything above GMT -11, it updates in the wrong direction. My time zone is GMT -5. If I set to GMT -11, or GMT -12, etc, the script updates me to GMT -29. Going in the other direction, GMT +11, GMt +12, etc, it updates back to GMT -5, which is correct. Hope all that makes sense...
Zelda-King
03-29-2003, 12:02 PM
Yes, I have people who's offset is +11. They don't set it (so on the boards it's listed as offset 0) and it updates to -13.
I've updated the ZIP. To fix the error, replace hi_timezone with the updated one in the instructions. Then, replace updatezone.php with the one in the file. Sorry for the inconvenience.
Smoothie
03-29-2003, 05:01 PM
Hey Nick, is this based on the actual time zone, or the users computer time?
Computer time. That's all there is to go on.
Smoothie
03-29-2003, 05:26 PM
A user on my forums made a comment that even though he has his time zone correct, his computer time clock is running slow...he keeps getting prompts to update his timezone.
So how far off can it be before this script keeps popping up?
Zelda-King
03-29-2003, 05:36 PM
My offset is 0 (my true offset). If I set my options offset to +12 it goes to -12. If I set it to -12 it goes to 0 like it should.
Also, nothing against the coding of the hack but my firewall blocks the javascript. Just so you know some users might be unaffected by this hack.
Today at 12:26 PM Smoothie said this in Post #14 (https://vborg.vbsupport.ru/showthread.php?postid=375139#post375139)
A user on my forums made a comment that even though he has his time zone correct, his computer time clock is running slow...he keeps getting prompts to update his timezone.
So how far off can it be before this script keeps popping up?
Depending on how slow his computer clock is, it should only appear in maybe the first two or three minutes of the hour. It shouldn't be a huge nuisance, though, if you only activate it on index.php.
Smoothie
03-29-2003, 05:44 PM
would be helpful if you put version numbers in the timezonehack.txt file so we know if we have got the latest.
Smoothie
03-29-2003, 05:46 PM
Just tested the latest version, you seem to have fixed the GMT -12 bug.
Smoothie
03-29-2003, 08:08 PM
blah....for some reason, in this latest version, the JS keeps popping up for guests, telling them they're timezone is incorrect......
To fix the problem with guests getting the alert, just re-apply step one. Updated ZIP attached.
Zelda-King
03-30-2003, 10:19 AM
I still have the -12 problem if I set my offset to +12.
OK. I just gave it another try on my forums, and I was unable to reproduce the problem. Maybe you should start from scratch and install the hack over again.
Zelda-King
03-30-2003, 10:37 PM
I just did. It seems to have worked. Now I have a daylight saving issue. That might be to do with vBulletin itself though. It updates my offset to +1 instead of 0.
I'm having the same problem. I'm thinking maybe there was a change for DST last nite or something.
Zelda-King
03-31-2003, 10:08 PM
Yes. I didn't explain that well. It sets it to the right time but in my options it's set to +1 instead of 0, like my forums are an hour behind.
EDIT: Oh, never mind... I think. Apparantly it's because clocks go forward in the UK a week before the US.
Erwin
04-01-2003, 02:22 AM
Day Light Saving happened in between 30th and 31st of March. :)
Boofo
04-01-2003, 02:29 AM
Are you sure? It happens on April 6th here.
Smoothie
04-01-2003, 05:51 AM
Yesterday at 11:29 PM Boofo said this in Post #27 (https://vborg.vbsupport.ru/showthread.php?postid=376203#post376203)
Are you sure? It happens on April 6th here.
He's not in the USA.
Boofo
04-01-2003, 06:08 AM
I know. I thought DST was a world wide thing happening at the same time.
Smoothie
04-01-2003, 06:22 AM
<a href="http://www.timeanddate.com/worldclock/custom.html?continent=australasia" target="_blank">http://www.timeanddate.com/worldcloc...nt=australasia</a>
Smoothie
04-01-2003, 06:23 AM
Today at 03:08 AM Boofo said this in Post #29 (https://vborg.vbsupport.ru/showthread.php?postid=376226#post376226)
I know. I thought DST was a world wide thing happening at the same time. Nope!
Smoothie
04-01-2003, 06:26 AM
for example, Sydney:
DST ended on Sunday, March 30, 2003, at 3:00:00 AM local daylight time
DST starts on Sunday, October 26, 2003, at 2:00:00 AM local standard time
ElmGoodie
05-11-2003, 01:45 AM
Iv'e istalled it, but nothing happenes.... nothnig! no JS no nothing...
why?
You probably missed a step.
ElmGoodie
05-11-2003, 09:07 AM
nope, did all of the steps that are written in the timezonehack file...
Erwin
05-11-2003, 10:35 AM
This hack works very well. :) Thanks.
I've made a small mod.
Instead of adding the code to your global.php (and save yourself a PHP file edit and headaches when you upgrade), you can add this to the bottom of your phpinclude template:
if ($dotimezonecheck AND ($bbuserinfo[usergroupid] == 2 OR $bbuserinfo[usergroupid] == 5 OR $bbuserinfo[usergroupid] == 6 OR $bbuserinfo[usergroupid] == 7)) {
$nowhours=vbdate("H",time());
eval("\$timezonecheck = \"".gettemplate('hi_timezone')."\";");
}
I changed the code a bit to make it so that only registered members and staff will get the popup to update the timezone. Members awaiting email registration, banned members etc. will not get it. I didn't want members still waiting email registration to get the timezone update, as they are not meant to be able to access their user CP as such. :)
Erwin
05-11-2003, 11:04 AM
A small bug:
If your server time is 10:01 but your computer time is 9:59 (ie. a difference of 2 minutes) the timezone hack thinks that you are off by 1 hour, and will activate, and move your time back by 1 hour by mistake. You then have to manually change the timezone back. This only happens when the small difference goes from 1 hour to the next.
Not sure how you can fix it.
Erwin
05-12-2003, 12:38 AM
Okay, I've had to remove this. :) It added an extra query each time a member visits forumhome to check the timezone, and it really didn't work when there was a few minutes difference, and the time changes over the hour. Maybe make it so that any minutes with 50-59 or 01-09 were excluded, so that the 10 minutes before or after the hour change, the timezone won't be checked, for computers which are just off by a few minutes.
Yeah, don't sweat it. Even I removed it.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.