Monday, October 5, 2015

How To Fix date_default_timezone_get() Warning While Installing Symfony?

I am using MAMP for my server and symfony 2.7.5.
I want to generate bundle with command line. But I have this Exception error on my console:
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 'UTC' for 'CEST/2.0/DST' instead 

1. Check date.timezone parameter in php.ini file (MAMP/bin/php/php5.5.18/conf/php.ini) and uncomment (remove this symbol ';' from beginning of the string) and set as follows

   date.timezone = "Europe/Berlin"

2. If the problem is still there, check where the CLI php.ini is located: 

   php -i | grep "php.ini"

In my case I ended up with : Configuration File (php.ini) Path => /etc

Then cd .. all the way back and cd into /private/etc/, do ls in my case php.ini didn't show up, only a php.ini.default

3. Now, copy the php.ini.default file named as php.ini:

  sudo cp php.ini.default php.ini

4. In order to edit, change the permissions of the file:

   sudo chmod ug+w php.ini

   sudo chgrp staff php.ini

5. Initialize configuration parameter date.timezone in your php.ini. You must open your php.ini with superuser privileges and edit the php.ini file:

   sudo mcedit /private/etc/php.ini 

   or nano /private/etc/php.ini

6. Search for [Date] and make sure the following line is in the correct format:

   date.timezone = "Europe/Berlin"

7. Save the changes and restart the server.


No comments:

Post a Comment