I'm running PHP 5.3.0 (installed as part of OS X upgrade to Snow Leopard) and am getting the following warnings when I view /q=cite/[nid]:

# warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting 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 selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /Library/WebServer/Documents/drupal6/sites/default/modules/cite/cite.module on line 186.

# warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting 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 selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /Library/WebServer/Documents/drupal6/sites/default/modules/cite/cite.module on line 192.

Comments

ki’s picture

Assigned: Unassigned » ki
Status: Active » Needs review

It seems to be a warning introduced by PHP 5.3 (http://drupal.org/node/598636).

The quick fix on user side would be to set the timezone in php.ini.

Can you insert the following lines at line 13 (cite.module) inside cite_init() and see if it works for you?


if (!date_default_timezone_get()) {
  date_default_timezone_set('UTC');
}

I hope core addresses this issue site wide though.

ki’s picture

According to PHP manual (http://www.php.net/manual/en/function.date-default-timezone-get.php), date_default_timezone_get() will still throw the warning without timezone set.

Any suggestions are welcome.

twoblackeyes’s picture

Is there any way to patch this? I'm developing on my OS X 10.6 machine as well and this error is all over the place.

UPDATE Here's helpful instructions for hard-coding your timezone with php.ini on OS X 10.6

http://supercali.inforest.com/forum/viewtopic.php?id=817

Note: Activating the entire contents of php.ini.default nuked something and my site wouldn't load. But if you save a new php.ini file with only the date settings:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "America/New_York"

; http://php.net/date.default-latitude
;date.default_latitude = 31.7667

; http://php.net/date.default-longitude
;date.default_longitude = 35.2333

; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333

; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333

...everythign appears to be working, and the timezone error is gone on my development machine. Obviously update the string for your own timezone. You can verify that it's working under the 'date' section of phpinfo().

markj’s picture

Since this seems to be an issue with PHP 5.3.0, why not add this to cite_init() and mark it as a known issue with that version until core does fix it:

<?php
  $php_version = phpversion();
  if ($php_version >= '5.3.0') {
    date_default_timezone_set('UTC');
  }
?>

If people need to manually add their own timezone instead of 'UTC' they can.

ki’s picture

Since it would need to set timezone only if timezone is not already set, we'd need a conditional.
Something like,

  $php_version = phpversion();
  if (!@date_default_timezone_get() and $php_version >= '5.3.0') {
    date_default_timezone_set('UTC');
  }

Would @ suppress the warning here?

markj’s picture

I'll check @ tonight, as the problematic environment is on my laptop, which is at home.

markj’s picture

Nope, @ doesn't do it.

ki’s picture

Status: Needs review » Needs work

That's a tricky little devil, isn't it?

I will wait and see if there is a way to gracefully handle it.

If I don't, I'd have to close the issue as "won't fix".

npoleon06’s picture

I am getting the same error after enabling the AGGREGATOR module and running CRON.

scripter2008’s picture

I'm new to drupal and see this error in various places. Lately when I was looking at how to ban an IP I saw the error appear in troll.admin.inc at lines 617, 642, 647 and 652. I'm using drupal 6.14 with PHP 5.3.0 as well.

cannedbrain’s picture

Try to add this configuration to your 'settings.php' file (inside /sites/default folder or /sites/yoursite.com):

ini_set('date.timezone', 'Asia/Jakarta');

Change the timezone to yours accordingly. Seems good so far. I'm using drupal 6.16 on Mac OS X Snow Leopard, btw.

fradipa’s picture

Ciao a tutti,

moving from php 5.2.x (apache/linux) to php 5.3 (apache/Mac Os 10.6.4),
I had the same problem...

The warning desappeared - as stated in #3 - adding:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Europe/Rome"

to php.ini

Bye

ki’s picture

Status: Needs work » Closed (won't fix)

If you are using PHP 5.3, please follow instructions either in #11 or #12.

#11 affects only the site that contains the settings.php.
#12 affects all sites.

escapeit’s picture

To find a valid timezone value:
http://php.net/manual/en/timezones.php

taggartj’s picture

I was getting the same issue in
modules/aggregator/aggregator.pages.inc on line 259

so i put
[Date]
; Defines the default timezone used by the date functions
date.timezone = "Australia/Melbourne"
in a file called php.ini on my site's root folder and it fixed it (i hope)

redaccion’s picture

#3 This work for me... Tnks¡¡¡

astra’s picture

My site under D5 got the same problem after upgrading to php5.3

Try to add this line to my settings.php

ini_set('date.timezone', 'Europe/Paris');

It seems to fix this problem for this site.