Warning: date() [function.date] error with php

started at 20 Jul 2009 by Dan
  • Dan
    20 Jul 2009

    I am working with a fresh install of php 5.3.0 and I am getting blocks of errors like this:

    Warning: date() [function.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/Anchorage' for 'AKDT/-8.0/DST' instead in /Users/dan/Sites/pfrr/wp-includes/functions.php on line 112

    from pages in wordpress.
    I did a few google searches but mostly found web sites with similar errors, not discussions about what is causing the error.

    Any ideas?

  • Richard
    20 Jul 2009

    The only thing I can think of is that this has changed in recent versions. You are now required to define the timezone:

    http://nl3.php.net/manual/en/function.date.php

    date_default_timezone_set('UTC');

    before you call date();

    Make sue your timezone string exists or is valid.

  • Dan
    22 Jul 2009

    Yes this works. But if you are using software like Wordpress and do not want to re-edit files every update, or worry about where to place the above funciton you can edit your own php.ini file.

    Place a line like:

    date.timezone = "America/Anchorage"

    You can find valid time zone strings at http://nl3.php.net/manual/en/timezones.php

    Thanks for the help!

  • LarryL
    01 Aug 2009

    I'm getting the same errors and put a date.timezone = "America/Chicago" directive in /etc/php.ini, but I'm still getting the errors after a complete restart:

    [Sat Aug 01 16:33:09 2009] [notice] Apache/2.2.12 (Unix) DAV/2 PHP/5.3.0 configured -- resuming normal operations
    [Sat Aug 01 16:34:25 2009] [error] [client ::1] PHP Warning: set_magic_quotes_runtime() [function.set-magic-quotes-runtime]: 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 'CDT/-5.0/DST' instead in /Library/WebServer/Documents/roundcubemail-0.2.2/program/include/iniset.php on line 62

    Got any ideas?

  • Richard
    02 Aug 2009

    Yes, create a test page with just displaying the phpinfo() output. Find out what the configured location should be of your php.ini

    It might be in /usr/local/php5/lib/ instead of /etc

  • loizos
    28 Aug 2009

    thanks Dan it works on me. i use opensuse and on the /etc/php5/apache2/php.ini on [Date] part date.timezine i enter Europe/Sofia with out "" and it works.

Reply

You must log in to post.