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

前端 未结 10 2143
悲哀的现实
悲哀的现实 2020-12-14 07:46

Can anyone tell me why am I getting this error when running app/console in a brand new formatted macbook with the latest MAMP installed ?

Warning: da

10条回答
  •  鱼传尺愫
    2020-12-14 08:08

    At AppKernel.php write:

    public function init() {
        date_default_timezone_set( 'Europe/Lisbon' );
        parent::init();
    }
    

    Since init() is deprecated (and will be remove in Symfony2 3.0) it is recommended to move the code in the constructor as in the following exemple:

    public function __construct($environment, $debug) {
        parent::__construct($environment, $debug);
        // get rid of Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone
        date_default_timezone_set( 'Europe/Paris' );
    }
    

提交回复
热议问题