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

前端 未结 10 2110
悲哀的现实
悲哀的现实 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 07:49

    By default Mac uses in the console the PHP located at:

    /private/etc/php.ini

    You should use this one because MAMP always unset the timezone variable and you would always get that error.

    0 讨论(0)
  • 2020-12-14 07:50

    I had the exact same problem with my SF2 installation.

    To fix this just go into your php.ini file at /etc/php.ini and change your file to look like this (adjust your timezone to suit your local timezone):

    ;;;;;;;;;;;;;;;;;;; ; Module Settings ; ;;;;;;;;;;;;;;;;;;;
    
    [Date] 
    ; Defines the default timezone used by the date functions 
    ; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone 
    date.timezone = Europe/London
    
    0 讨论(0)
  • 2020-12-14 07:51

    I had the same problem, and it's true there is a command line, and MAMP/Native Mac PHP service running on Yosemite, and while I was trying to follow the directions on this page non of them seemed to work for me.

    When I ran php command:

    $ php -i | grep 'Configuration File'<br>
    Configuration File (php.ini) Path => /etc<br>
    Loaded Configuration File => <em>(Blank)</em>
    

    I realized that the php.ini that the CLI was using, was actually php.ini.default file. I created a symbolic link to that file as the php.ini and everything worked.

    My-MacPro:/etc/$ ln -s php.ini.default php.ini

    0 讨论(0)
  • 2020-12-14 07:53

    You don't edit the good php.ini file

    You can get a full phpinfo() using :

    php -i 
    

    And, in there, there is the php.ini file used :

    $ php -i | grep 'Configuration File'
    Configuration File (php.ini) Path => /etc
    Loaded Configuration File => /etc/php.ini
    
    0 讨论(0)
  • 2020-12-14 07:58

    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.

    0 讨论(0)
  • 2020-12-14 07:59

    I did follow your answers, but in my case none of them worked. I decided to go change the date_default_timezone_get() in the logger.php file.

    I replaced with my timezone setting ("Europe/Berlin"), and all went well !

    Old school solution but still a solution.

    0 讨论(0)
提交回复
热议问题