Friday, August 30, 2013

Symfony2: Warning: date_default_timezone_get()

This is one way to solve the Waning: date_default_timezone_get(). The problem occurs when you try php app/console doctrine:schema:create command in the terminal and then it shows up the warning:
Warning: date_default_timezone_get()
This can be solved by changing the Php path point to MAMP.
If you are using the MAMP in OSX,  you currently have at least 2 installed PHP- OSX and MAMP.
Here is the commands to change PHP's path to MAMP, open your terminal and type the following commands:
$ sudo mv /usr/bin/php /usr/bin/php-bak
sudo ln -s /Applications/MAMP/bin/php/php5.x.x/bin/php /usr/bin/php
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/bin/mysql

Lastly, you must add  date.timezone = "Europe/Berlin" to a php.ini which is stored in /Applications/MAMP/bin/php/php5.x.x/conf

That's it!

NOTE: 
* Don't forget to change php5.x.x to map your php version.
* Change the date.timezone to suit your timezone, for example, "Europe/Berlin", "Asia/Bangkok".

No comments:

Post a Comment