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

前端 未结 7 1624
旧时难觅i
旧时难觅i 2020-11-27 12:43

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          


        
相关标签:
7条回答
  • 2020-11-27 13:48

    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 http://php.net/manual/en/timezones.php

    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:

    <?php     
    
    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);
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题