Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
609 views
in Technique[技术] by (71.8m points)

symfony - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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' );
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...