3

Presuming alternating DST is no longer an issue, I'm confused about the new change. It seems there is now only one configuration option but that is just for the server's time zone:

This setting lets you specify the time zone where your server is located.

And they give a clear warning if you just put whatever you feel like:

If you do not set this preference so that it correctly reflects the location of your server it may cause problems with your dates and times. If you are not sure where you server is located please ask your hosting provider.

So what if we want the system to go by a different timezone setting, e.g. my server is in GMT, but my members, activities, etc. are primarily in New York (GMT-5)?

What are the config settings for this now? There seems to be a new setting, "time_reference":

/*
|--------------------------------------------------------------------------
| Master Time Reference
|--------------------------------------------------------------------------
|
| Options are "local" or "gmt".  This pref tells the system whether to use
| your server's local time as the master "now" reference, or convert it to
| GMT.  See the "date helper" page of the user guide for information
| regarding date handling.
|
*/
$config['time_reference'] = 'local';

But how do we set a different default timezone for the site? Are one of the old configs still used for that? Can't seem to get it straight.

Related questions pre 2.6:

Forcing DST settings for users

How are we supposed to manage time and respect localization/DST in EE?

1 Answer 1

2

For the values of the timezone variables below you can use both PHP timezones (e.g. America/New_York) and CodeIgniter Timezones (e.g. UM5).

Through some tests (using print_r($this->EE->config->config);):

$config['server_timezone'] is for your server's timezone.

$config['default_site_timezone'] is for your site purposes.

What you choose on CP Home > Administration > Localization Settings sets $config['server_timezone'] with a PHP Timezone. $config['default_site_timezone'] remains empty, if it is not manually set in your config.php or bootstrap then the value of $config['server_timezone'] will be used instead.

As of this writing (EE 2.6.1) you must manually set $config['default_site_timezone'] to a CodeIgniter Timezone because for date entry fields their field_dt_# column in the database can only accept up to 8 characters, meaning the PHP Timezone in $config['server_timezone'] will not be properly saved and thus changing the value in your date entry fields every time you save it as Fixed. You can also save $config['server_timezone'] as a CI value and be done with it if your site and server timezones are the same, however, the select dropdowns on the Localization Settings page will not reflect your settings.

A new config is added, too:

$config['tz_country']

But it is not clear what this does asides from help populate the dropdown.

7
  • Did you just make a quick plugin to test that? Ah yeah, I fiddled with tz_country briefly before, too, did some more just now to make sure. tz_country is the country dropdown, server_timezone is the dropdown afterwards. The latter takes precedence over the former, but if not set then tz_country is used at least in the dropdown selection. Format for former is like us, gb, etc. format for latter is the php.net link you gave. Alright I gotta test default_site_timezone as different from server_timezone when I get the chance. Thanks.
    – notacouch
    Jun 2, 2013 at 18:42
  • 1
    @notacouch, just erase the timezone related config variables of config.php. Then, enable php on a file and print the value of ee()->config->config
    – Sobral
    Jun 2, 2013 at 21:32
  • Okay tested this out. For me default_site_timezone remains blank. If you do not set it explicitly using CI timezone references you are bound to get errors. While both PHP/CI tz's are fine for both the above config and server_timezone, by default EE saves the latter in PHP format. If default_site_timezone is not set it will default to server_timezone, however, field_dt_# can only store 8 chars. Better to save server_timezone in the PHP tz (so in the CP the dropdowns autoselect) and default_site_timezone in the CI tz (so no breakage).
    – notacouch
    Jun 5, 2013 at 19:43
  • @notacouch, please, edit my answer with your tests and conclusions!
    – Sobral
    Jun 5, 2013 at 21:12
  • 1
    EE 2.7 apparently deprecates server_timezone, see "Developers" in their release notes. Haven't gotten around to updating yet, curious what the implications are.
    – notacouch
    Sep 4, 2013 at 20:11

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.