Ticket #4994 (closed defect (bug): fixed)

Opened 4 years ago

Last modified 3 years ago

Default Timezone settings

Reported by: redbeard0x0a Owned by: westi
Priority: normal Milestone: 2.8
Component: General Version: 2.3
Severity: major Keywords: has-patch needs-testing early
Cc:

Description

I setup Beta3 on  NexentaCP (an  OpenSolaris distribution, downstream from Ubuntu), the php error notifications are set as E_ALL & ~E_NOTICE, yet I get these messages when working with dates:


Warning: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We had to select 'UTC' because your platform doesn't provide functionality for the guessing algorithm in /var/www/wordpress/wp-includes/functions.php on line 14

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We had to select 'UTC' because your platform doesn't provide functionality for the guessing algorithm in /var/www/wordpress/wp-includes/functions.php on line 23


These warning messages make wordpress completely unusable out of the box without having to hard code timezones in either php.ini or templates. The warnings appear 15 times on the front page of a default install of wordpress 2.3 beta3. There should be a way to explicitly set the timezones for the wordpress installation.

Some documentation I found regarding this issue:  https://answers.google.com/answers/threadview?id=739376  http://us2.php.net/manual/en/function.date-default-timezone-set.php

Attachments

4994.diff Download (487 bytes) - added by Nazgul 4 years ago.
4994.r6668.diff Download (1.4 KB) - added by darkdragon 4 years ago.
Sets the default timezone based off of the settings in gmt_offset for the blog. Does this, even if it is already set. Based off of r6668
4994.2.r6668.diff Download (1.2 KB) - added by darkdragon 4 years ago.
Second patch sets the default timezone to GMT to work with the wordpress calculations for GMT offsets. Based off of r6668

Change History

Should be mentioned that this is a PHP >5.2 setup.

this can be solved in wp-settings.php

if (PHP5) {
  date_timezone_set('UTC');
}

And only on hosts that don't already set this value.

The reason it isn't a 5.1 problem is that DateTime isn't included by default.

  • Milestone set to 2.3

Nazgul4 years ago

  • Keywords has-patch needs-testing added

Could you try the attached patch?

It sets the timezone to UTC if it's an affected version of PHP and both the TZ environment variable and the date.timezone ini setting aren't set.

comment:5   f00f4 years ago

Make a user option for it. I would not like UTC in my blogs and on a shared hoster one usually can not change env vars / php.ini settings.

How the default works is that you set it first and then you change it whenever you need to. The DateTime classes allow you to create timezones on the fly, so it wouldn't be an issue if PHP4 compatibility wasn't required. However, you can still change it when you get passed the point where the option file is included and have access to that API.

It should probably be a function, in that case.

Traction seems to have been lost on this. For such a trivial problem with a trivial solution it should be committed.

Sets the default timezone based off of the settings in gmt_offset for the blog. Does this, even if it is already set. Based off of r6668

Patch uses the setting in the gmt_offset to set the timezone and does this even if the default timezone has been set. Some hosts set the timezone based on where the servers are located. So this will keep the time functions where the blog admin is located. Will not work per user, so it might be worth setting it to GMT instead so that the time calculations work.

Second patch sets the default timezone based off of GMT to work with WordPress gmt offsets for both the server and users.

Second patch sets the default timezone to GMT to work with the wordpress calculations for GMT offsets. Based off of r6668

  • Keywords early added
  • Owner changed from anonymous to westi
  • Status changed from new to assigned

Moving to 2.6 - needs doing early in a release cycle

suggesting wontfix. no activity, and E_STRICT errors are being worked out of trunk, in php pre-5.2, 5.3 and even 6.0. See: #8701

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Milestone changed from 2.9 to 2.8

fixed when when changed the error_reporting stuff in 2.8

Note: See TracTickets for help on using tickets.