Timezone / HourOffset problem
My vanilla forum (running 2.1) is based in germany, so all times should be GMT+1 (EST) or GMT+2 (CEST) when it's daylight saving time.
I noticed, that GMT+0 times where shown for logged out users, so I changed the default timezone in bootstrap.php
date_default_timezone_set('Europe/Berlin');
(I would like to keep it that way, as this also fixed numerous problems with plugins showing the wrong time and the smarty time functions.)
Now, for logged out users, times are correct, but for users that are logged in, 2 hours are being added to the time, so GMT+4 times are shown.
Setting the the HourOffset in the Database to 0 for everyone will not work, as it is set back to 2 by global.js:
var d = new Date() var hourOffset = -Math.round(d.getTimezoneOffset() / 60); // Set the ClientHour if there is an input looking for it. $('input:hidden[name$=HourOffset]').livequery(function() { $(this).val(hourOffset); });
see https://github.com/vanilla/vanilla/blob/ee5f4dd1d1d57e025bae5ca4806a99fc90b69675/js/global.js#L1138
Date().getTimezoneOffset() calculates the offset in minutes to UTC/GMT time.
I could just comment this out, but I think this is a bug in Vanilla as the Hour Offset calculation should use the server time and not UTC/GMT.
Is there any way I could change this, so the HourOffset calculation uses the server time?
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
Comments
couldn't you just add the difference between your server time and utc time to the hour offset.
either +2 or -2 not sure what you should be.
the js by the way is performed on your client not on your server.
you would need to get the timezone of your server from php and make js get it from the php routine with ajax or something else, if you wanted it automated.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Sure, but I would have to change that everytime its daylight saving time and changing the core files to show the correct local time seems wrong.
My question was actually more in the way of: "Is the server time available in vanilla js and if not, how could I inject it to make this work?"
Sorry if i was unclear.
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
Don't hack bootstrap.php. The config setting is Garden.GuestTimeZone.
Thank you, that did the trick! Didn't know of that config setting.
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
Sure thing
Is there an easy way to change timezone?
As I understand, vanilla is pulling my server's time is that correct? The problem is that the server is in USA but website directed to latin america users, so I need to correct the timezone.
Thanks!
No, latin american users that are logged in should see their timezone correctly.
Vanilla sets the internal time to UTC and then adjusts the time shown to logged in users to match their computer clock.
Guests will see UTC though, so you would add this config value:
You can find a list of valid values here:
http://php.net/manual/en/timezones.php
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS