You are here

PHP Warning: Unknown: It is not safe to rely on the system's timezone settings

Submitted by Druss on Sun, 2014-08-17 02:14

After upgrading a Debian install to use PHP 5.4, I ran into the following error:

PHP Warning:  Unknown: 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0

The easiest way to fix this (especially on Debian's PHP installs which has a weird .ini setup) is to create a separate .ini file. IOW,

  1. Go to /etc/php5/conf.d
  2. Create a file named timezone.ini
  3. Add the following into it: date.timezone = "America/Indianapolis"

    You can find your own timezone here.

  4. Now, restart Apache (if that's your webserver) using
    apache2ctl graceful

Hope this helps :)