Drupal 6.14
PHP 5.3.0

I'm trying to set up a view that sorts by date. When adding a sort filter that includes my newly created event node the following warnings run amok. Certain I've correctly set the date/time functionality and followed all troubleshoot steps. What am I missing?

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/Chicago' for 'CST/-6.0/no DST' instead in /Library/WebServer/Documents/sites/all/modules/date/date_api_sql.inc on line 557.

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/Chicago' for 'CST/-6.0/no DST' instead in /Library/WebServer/Documents/sites/all/modules/date/date_api_sql.inc on line 558.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ghosts’s picture

I believe this is a PHP 5.3 issue. I'm having the same problem and am interested in a solution.

ghosts’s picture

added the timezone to php.ini and solved the problem

jonvk’s picture

Same as #2 lsburton.

marvil07’s picture

Version: 6.x-2.4 » 6.x-2.x-dev
Category: support » bug
Status: Active » Needs review
Issue tags: +PHP 5.3
FileSize
2.05 KB

Yep, setting timezone to php.ini solve the problem, but we also need to make sure we do not need it, so here it's a patch for that :-)

marvil07’s picture

Title: Correctly setting the timezone. warnings stemming from the views/filters/node type » Avoid timezone warnings
FileSize
3.43 KB

Hey, I notice some more of this in date_popup, new patch!

marvil07’s picture

Title: Avoid timezone warnings » Avoid timezone warnings in PHP 5.3
Assigned: Unassigned » marvil07
Status: Needs review » Needs work

Ok, there are a lot of places in date api where date() is used without a timezone, so, instead of changing in places where I receive the notice, I'm now trying to review the entire source.

Basically changing

date($format);

to:

date_format_date(date_now(), 'custom', $format));
marvil07’s picture

Assigned: marvil07 » Unassigned
Status: Needs work » Needs review
FileSize
6.36 KB

Great, there were not so many places :-p

verta’s picture

subscribing

becw’s picture

Why not use the date_default_timezone_set() function that the PHP warning recommends, with Drupal's own core timezone setting?

/**
  * Implementation of hook_init().
  */
 function date_api_init() {
+  date_default_timezone_set(date_default_timezone_name());
   drupal_add_css(drupal_get_path('module', 'date_api')  .'/date.css');
 }

Though since the timezone setting is part of Drupal core, maybe *that* should be handling the timezone setting...

agerson’s picture

+1
subscribe

tayzlor’s picture

subscribing to this, will test patch shortly.

lukenn’s picture

subscribing to this

lukenn’s picture

sorry, double post.

KarenS’s picture

Status: Needs review » Fixed

There was a reason I didn't do that in the first place, but I agree we need a fallback setting now. I can't believe PHP is yelling about this, but anyway...

One change is needed, I have to make it:

  if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set(date_default_timezone_name());
  } 

Because in Drupal 6 we still support PHP4, where that function does not exist. We won't need that test in Drupal 7.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

thatjustin’s picture

Lots of people, myself included, solved this problem by adding the timezone to php.ini Here's exactly what to change:
Find php.ini, it's most likely at /etc/php.ini
Find your timezone here: http://www.php.net/manual/en/timezones.php
Say your timezone is America/Los_Angeles, change this line accordingly:
From:

;date.timezone = 

To:

date.timezone =  America/Los_Angeles 
roadsideok’s picture

#16 worked for me. date.timezone did not have a value at all.