About timezones and hour offset
Hi,
I've read a lot on these forums about timezone and hour offset settings but can't seem to find a solution to my problems
I'm testing Vanilla 2.1.1 before migrating from another forum software and I live in France where my server is hosted. According to my phpinfo, the timezone settings look correct :
Without any change in my config settings, the time for guests is not correct, it is printed as UTC (we are in UTC+1 in France, +1 hour with DST, so +2 hours from UTC), if I add $Configuration['Garden']['GuestTimeZone'] = 'Europe/Paris';
in my config.php, the time is correct for guests.
When I login, the time is in UTC. If I edit manually the field hourOffset in my database to 2, the times are correct and stay correct. I've tried creating a new account and the time appears in UTC and hourOffset is set to 0 for this new user. (Just in case, my computer timezone is set to UTC+1, changing it doesn't change anything).
I would like to understand how the field hourOffset is updated, and why it doesn't update to the correct value when the user is connected. It looks like a recent change has been made in global.js regarding hour offset, it would be possible to specify a default offset in config.php ? Would this solve my problems ?
Any advice would be appreciated to help me solve this.
Thanks,
Kaliceos
Comments
Yes, that is a bug in Vanilla 2.1.1
If you apply the change you linked to (line 1151-1157) to your js/global.js, everything should work.
Unfortunately, there is no better solution right now (other than waiting for 2.1.2)
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
Applying the change seems to work, it forces the change in the database, and puts the correct hourOffset. I will have to try with my canadian members to be sure that it works.
Thanks for your help
The hour offset is calculated client side and updated via AJAX if it differs from the stored offset. The patch linked is required since JS definitions were refactored.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Hey guys, I could use some advice. I have this same issue, although it doesn't affect USA EST members since the server time and bootstrap.php time are both set to America/New_York. A friend in Australia has times shown as +10 hours as opposed to reality.
I applied the code change to my global.js, and a little while later, the entire forum started having problems. It wouldn't embed, JavaScript in general did not work, and (as an admin) when going to 'Messages' in the Dashboard, I was presented with 'You do not have the proper permissions...'. After reverting the change, and clearing cache on browsers, everything started working again. Damn near gave me a heart attack.
I'm wondering if this may have somehow been caused by enacting the change on a live production forum. Do you think waiting a period of time to pass (so that timeoffsets and the actual time sync up/aren't in the past/future) would allow things to function? Any advice?
Thank you again in advance for the help, it is much appreciated. I've been lurking here for about two weeks and it's nice to see some active support members in the community. Regards.
don't change bootstrap.php from the original! which is here 2.1.1
https://github.com/vanilla/vanilla/blob/2.1/bootstrap.php
$Configuration['Garden']['GuestTimeZone'] = 'America/New_York';
the houroffset doesn't update properly. you can manually set it. in user table.
try the change Bleistivt suggested.
if it introduces a js error, it will cause js functions not to load properly causing issues.
personally I haven't tested, but I know 2.1.1 doesn't correctly set new users to the correct time offset. although older users from previous versions should have correct hour offsets.
next time check your console for js errors.
perhaps you got this - which killed your global.js
ReferenceError: gdn is not defined
var setHourOffset = parseInt(gdn.definition('SetHourOffset', hourOffset));
just changing those 4 or 5 lines. i believe will break things because gdn definition is not set.
As an experiment - I replaced the whole global.js from master and installed it in 2.1.1
https://github.com/vanilla/vanilla/blob/master/js/global.js
and the hour offset was updated for the user.
But, I can't recommend doing this on a live forum because I don't know what the other implications are.
perhaps - @linc will chime in - perhaps not. time will tell.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
A QUICK backport would be nice.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Peregrine, thank you.
I set bootstrap.php back to UTC (which is what bootstrap.php was originally, even though though server I think is located in timezone 'America/New_York').
I added $Configuration['Garden']['GuestTimeZone'] = 'America/New_York'; to config.php.
So now I should be okay to apply the global.js changes as Bleistivt mentioned, correct?
Well I didn't see a pull request :disappointed:
Anyway: http://vanillaforums.org/discussion/27822/vanilla-2-1-2-security-release
I had a few other things that were equally pressing that needed to be finished first.
Thank you Peregrine and Linc! I'll upgrade now. You guys all rock as a community!!
Dawwwww. :relaxed: Thanks.
I just upgraded (and by upgrading, I mean overwriting everything and then re-uploading config.php). Still getting an error related to this exact time zone issue, as shown in the Chrome console for js errors.
Uncaught TypeError: undefined is not a function.
It appears right below the line: gdn.url('/utility/sethouroffset.json'),
Any hints? I'm now experiencing the same exact issue as earlier today.
Shouldn't there be a /utility/ directory to hold sethouroffset.json? I definitely don't have either, nor do I see one in the 2.1.2 release .zip?
@Coinstock No, utility is a controller, like 'discussion' or most any other in Vanilla.
I do not get that error in 2.1.2. You might try clearing your browser cache; it should do that automatically with the version increment but I've seen weirder problems.
thanks, will try.
@Coinstock Are you sure you're using the latest global.js from 2.1.2? I specifically moved that whole timezone section way down the file to be after all the gdn function definitions, and that is the only thing that changed there. If everything else was working in 2.1.1 it should continue working now.
@Linc Please see the pastebin of the global.js I just pulled out of the .zip from the download link for 2.1.2 in your post earlier. You will see that the piece of code in question shows as line 309.
http://pastebin.com/2EftFatT
Just to be sure, I just redownloaded the 2.1.2 .zip from http://vanillaforums.org/addon/vanilla-core-2.1.2 and I get the same global.js (with the code placed at line 309), and not farther down.
gdn.url appears to begin being defined on line 627.
Am I getting the .zip from the wrong place or perhaps making a layman's mistake?
The master global.js located at https://github.com/vanilla/vanilla/blob/master/js/global.js appears to have the changes you are referring to, with all functions referencing gdn.url placed below where gdn.url is defined, except one starting at line 250. gdn.url is defined at line 569. The timezone code is at 1150.
Edit: I replaced my global.js with the one from github and everything seems to be back to normal, but I think the global.js in the 2.1.2 .zip is not the same as the one on github.
I am having one of those "how did this ever work, then?" moments. In 2.1 gold, gdn.url was used on line 41 and it was working just fine.
So does that mean I'm crazy, or that gdn.url does need to be defined before the functions/code that use it? Generally, that's how it has been when I program, but I'm not familiar with JavaScript on that level.
My guess is the code creep slowly pushed it down accidentally. Which is a good thing because your company and colleagues make amazing software.
another note of noise from the peanut gallery
maybe it would be worth copying the entire master global.js to 2.1.x
at least there are no syntax errors
time zone works and buttonbar seems to work. not sure what would break though as mentioned previously.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.