Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAMP / Symfony: MAMP overrides date.timezone setting from php.ini, Symfony fails

Tags:

php

symfony

mamp

I'm trying to configure Symfony2 framework in MAMP.

In php.ini I have correctly set date.timezone, however, it appears that MAMP somehow overrides the setting and uses system time instead.

As a result, Symphony's config.php page sends this warning:

Warning: date_default_timezone_get() [function.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 'America/New_York' for 'EST/-5.0/no DST' instead in /Applications/MAMP/htdocs/Symfony/app/SymfonyRequirements.php on line 434

Symfony fails to show start page until this has been fixed. What would be the solution?

Thank you!

like image 360
Dimitri Vorontzov Avatar asked Nov 28 '12 00:11

Dimitri Vorontzov


2 Answers

Check if there are two php.ini files in your system. You may be adding the date.timezone line in one of them but MAMP is using the other.

If that doesn´t work for you try adding the following line at the beginning of your web/app.php and web/app_dev.php files, (as the error message suggests):

date_default_timezone_get('Europe/London');

Hope it helps.

like image 54
Juan Sosa Avatar answered Sep 25 '22 23:09

Juan Sosa


I am still working on figuring out why and how MAMP overrides the php.ini date.timezone settings, however, I have found the quick fix solution within Symfony php files, which solved the problem, at least for now.

I added the following bit of code:

date_default_timezone_set ('America/New_York');

-- at the top of Symfony's config.php and app_dev.php files, immediately after the opening php tag, at the very top of the script. This removed the warning message and got Symfony working on MAMP.

I foresee having to add the same code to some other php files inside Symfony as I keep hacking at it, which shouldn't be a problem. Or I may figure out how to override MAMP's overriding.

Still, this is a workable solution.

like image 25
Dimitri Vorontzov Avatar answered Sep 21 '22 23:09

Dimitri Vorontzov