MiloŇ° MiloŇ° - 1 year ago 220
PHP Question

Symfony2 and date_default_timezone_get() - It is not safe to rely on the system's timezone settings

I have a Symfony2 project. I updated my php to 5.5.7 today and since then, I am getting the

Warning: date_default_timezone_get(): 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...

I setup the default timezone in my php.ini

; Defines the default timezone used by the date functions
date.timezone = "Europe/Paris";

To be sure that this is the good php.ini, I was checking with


And the path I ma getting there is the one I am modifying:


But in there, I see the

Default timezone UTC

Which is strange.

any idea? Thank you.

sas sas
Answer Source

Maybe you are trying to set it in Apache's php.ini, but your CLI (Command Line Interface) php.ini is not good.

Find your php.ini file with the following command:

php -i | grep php.ini

And then search for date.timezone and set it to "Europe/Amsterdam". all valid timezone will be found here

Another way (if the other does not work), search for the file AppKernel.php, which should be under the folder app of your Symfony project directory. Overwrite the __construct function below in the class AppKernel:


class AppKernel extends Kernel
    // Other methods and variables

    // Append this init function below

    public function __construct($environment, $debug)
        date_default_timezone_set( 'Europe/Paris' );
        parent::__construct($environment, $debug);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download