Make WordPress Core

Opened 17 years ago

Closed 16 years ago

#4994 closed defect (bug) (fixed)

Default Timezone settings

Reported by: redbeard0x0a's profile redbeard0x0a Owned by: westi's profile westi
Milestone: 2.8 Priority: normal
Severity: major Version: 2.3
Component: General Keywords: has-patch needs-testing early
Focuses: 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 (3)

4994.diff (487 bytes) - added by Nazgul 17 years ago.
4994.r6668.diff (1.4 KB) - added by darkdragon 17 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 (1.2 KB) - added by darkdragon 17 years ago.
Second patch sets the default timezone to GMT to work with the wordpress calculations for GMT offsets. Based off of r6668

Download all attachments as: .zip

Change History (15)

#1 @santosj
17 years ago

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.

#2 @santosj
17 years ago

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

#3 @foolswisdom
17 years ago

  • Milestone set to 2.3

@Nazgul
17 years ago

#4 @Nazgul
17 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.

#5 @f00f
17 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.

#6 @darkdragon
17 years ago

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.

#7 @darkdragon
17 years ago

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

@darkdragon
17 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

#8 @darkdragon
17 years ago

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.

#9 @darkdragon
17 years ago

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

@darkdragon
17 years ago

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

#10 @westi
17 years ago

  • 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

#11 @Denis-de-Bernardy
16 years ago

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

#12 @Denis-de-Bernardy
16 years ago

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

fixed when when changed the error_reporting stuff in 2.8

Note: See TracTickets for help on using tickets.