Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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: 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /../Logger.php line 112

I have checked the path of php.ini and marked out the date.timezone = "Europe/Athens"

Also restarted MAMP/apache several times.

like image 311
Radolino Avatar asked Sep 22 '12 11:09

Radolino


2 Answers

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' );
}
like image 51
Filipe Fernandes Avatar answered Nov 06 '22 23:11

Filipe Fernandes


Default php.ini in OS X is located at:

/private/etc/php.ini

Anyway, you'll can either tell CLI php to load MAMP settings, or use an alias of MAMP command itself.

like image 21
moonwave99 Avatar answered Nov 06 '22 21:11

moonwave99