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
384 views
in Technique[技术] by (71.8m points)

php - Warning: date_default_timezone_get() installing Symfony

I'm trying to install Symfony on XAMPP and I keep getting numerous errors.

[SymfonyComponentDebugExceptionContextErrorException]                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
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 
/Applications/XAMPP/xamppfiles/htdocs/vendor/monolog/monolog/src/Monolog/Logger.php line 233 

and then

Script SensioBundleDistributionBundleComposerScriptHandler::clearCache handling the post-
install-cmd event terminated with an exception

and finally

[RuntimeException]                                                         
An error occurred when executing the "'cache:clear --no-warmup'" command.

I've tried changing the date.timezone in my php.ini file and using the date_default_timezone_set() function in the command line before trying to install it and nothing seems to work.

I've been staring at it for a while so any help is appreciated

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

If you can't set it correctly in your php.ini for some reason then you can set it as the first thing in your AppKernel, like so..

class AppKernel extends Kernel
{
    public function __construct($environment, $debug)
    {
        date_default_timezone_set('Europe/London');
        parent::__construct($environment, $debug);
    }

    public function registerBundles()
    {
        $bundles = array(
            ....
        );
    }

    ....
}

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

...