5

I noticed that my entry dates were being offset by one hour ahead and when I looked into the issue I found the user localization to be the problem. In my config file I have the following line:

$config['daylight_savings'] = date('I') ? 'y' : 'n'; // Autodetect DST

This was shamelessly lifted from Erik Reagan's Master Config file and it automatically sets the DST under Admin -> Localization Settings but it does not affect DST under My Account -> Localization Settings. Is there a way to set DST offsets globally for users like I can for the system or is it up to each individual to set this themselves?

2
  • It should change the value in the CP too - it does on all my servers (provided members can't override the system default). Dec 20, 2012 at 22:21
  • @JustinKimbrell it does update the Admin -> Localization switch but it has no affect in My Account -> Localization Settings. I've seen this on 2.5.2, 2.5.3, and now on 2.5.4. Dec 20, 2012 at 22:24

2 Answers 2

2

I have some pretty extensive experience with this issue as we run a live TV broadcast.

Quick answer to you question is to use $config['allow_member_localization'] = "n"; in your config.php. This prevents any per user localization despite what is stored in exp_members AND subsequently what shows up in the member's profile.

Once you set this there's three ways I have confirmed to set the default localization:

  1. Under Members -> View All -> (select a member) -> Member Preferences you'll see "Use this member's localization settings as the master site default?" which if checked will set the default localization to the same as that user's. The thought behind this is that a "Super Admin" would keep their DST/TZ settings up to date I assume.
  2. Under Admin -> Localization. This sets the two configurations variables I will mention in the next bullet in the database but it is PER SITE so you'd need to set it for each site.
  3. I HIGHLY RECOMMEND using a site-wide config.php to set these two values. $config['default_site_dst'] = (date("I")) ? "y" : "n"; and $config['default_site_timezone'] = "UM6"; Where UM6 is your timezone in EE's weird TZ formatting. Just be sure your server (and php) timezone is set properly (run "date" in the terminal to check).

There are also two other configuration values which I've seen floating around which I tend to ignore:

  1. $config['honor_entry_dst'] doesn't exist anymore as of some EE version before mine (which is 2.4.0).

  2. $config['daylight_savings'] this seems like the end all be all of settings but don't be fooled. My understanding of this variable based on scouring the source code is if you haven't used any of the prior methods to set the DST this is your default. I have NOT tested this as I end up just setting $config['daylight_savings'] = (date("I")) ? "y" : "n"; as well anyways.

I'd like to make one final note before signing off. I've always had to re-save entries made in a prior DST settings to get them back to the correct time. This is because the only data that is stored in exp_channel_data is the timezone not the DST setting which is rather unfortunate.

3

Per the EE docs on Date Localization this setting should work as you have it coded.

If people browsing your site are not members, or if they have not set a time zone preferences in their personal profile, the times will instead be shown according to your master system localization settings found in the Localization Settings area of your Control Panel.

Has the member you're testing set a time zone preference?


Also, it's possible this has been set:

If you prefer that the localization settings of a particular member be used as the site default this can be specified in the My Account ‣ Administrative Options page.

4
  • I started digging around myself and discovered these two things but I was still wondering if there is a way to set this in the config file I guess. I'm definitely going to start using the default settings option from my superadmin account that I have when I create each site. In fact I'm off to update my default ee install with this setting right now, but this only puts a band-aid on the problem as I now have to update this setting on my sites when DST changes. Dec 20, 2012 at 22:15
  • The code you are using is what you should use to set the DST. It should be working IMO. Is it not working for a logged in user or for a guest user? Also, you might need to account for your server's location if it's in a different timezone with an offset.
    – Anna_MediaGirl
    Dec 20, 2012 at 23:25
  • @MediaGirl If I leave the code in config.php it works as it should for Admin -> Localized settings (I can't change the setting manually) but for My Account -> Localized Settings I can change the DST setting at will, the config setting seems to have no affect on this. If I set the use as default setting in my superadmin Administrative Options panel then the setting is changed as expected. However, if I do this then I'll need to change the DST setting each spring and fall. What I want to be able to do is set all the DST settings from config.php which I currently don't seem to be able to do. Dec 21, 2012 at 0:50
  • With the setting in your config.php, a member can still be able to set their own personal DST setting if they want. This is part of their profile settings. I don't know of any way to override this except the "set as default" setting. But until they change their DST setting, it should default to the DST setting you have in config.php.
    – Anna_MediaGirl
    Dec 21, 2012 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.