0

I changed my date.timezone in php.ini (actually I did it in all 9 instances of php.ini file throughout the MAMP folder) from "Europe/Berlin" to "Europe/London" and since then I am getting this warning in MAMP phpinfo

Warning: phpinfo(): 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/MAMP/bin/mamp/phpinfo.php on line 2

Also when i try to use DateTime in my scripts browser comes up with folowing: Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings....

I guess I haven't changed the correct instance of php.ini?

Zel
  • 407
  • 1
  • 5
  • 12
  • Call `phpinfo()` to find out which php.ini is actually being used. The path should be one of the first lines printed. – Michael Berkowski Feb 24 '14 at 14:50
  • possible duplicate of [Dude, where's my php.ini?](http://stackoverflow.com/questions/8684609/dude-wheres-my-php-ini) – Michael Berkowski Feb 24 '14 at 14:52
  • Note, that you do need to restart Apache after modifying php.ini. – Michael Berkowski Feb 24 '14 at 14:52
  • I have done it. It's 5.4.10. I followed the correct path and it in php.ini file timezone is set to "Europe/London" but it still giving me the same warning/fatal error – Zel Feb 24 '14 at 14:57
  • Re: restarting Apache - I restarted the the local Apache server in MAMP, but still no joy. – Zel Feb 24 '14 at 14:59
  • @ Michael Berkowski. Thanks for your time, Michael. This question is not duplicate of Dude, where's my php.ini (love the title, though). I know where to find php.ini, I changed the timezone settings and everything went pearshaped. I tried to restore it to Europe/Berlin, but it keeps serving me the warning/error. It's probably clashing with some MAMP/PHP install setting, but for the life of me, I can't find it! – Zel Feb 24 '14 at 17:06

1 Answers1

0

From the error message:

... In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. ...

If it didn't error before you made the change, and it's erroring now, then this is the most likely explanation. Check very carefully that it is exactly:

date.timezone = "Europe/London"
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
  • @ Matt Johnson Thanks for your time, Matt. Yes, I checked and I checked again, jsut in case. This is the full Date paragraph from php.ini: [Date] ; Defines the default timezone used by the date functions ; Will be changed by MAMP to system timezone date.timezone = "Europe/London" – Zel Feb 24 '14 at 16:40
  • In searching the web, I found some places showing to use quotation marks, and others with them omitted. Does it work if you omit the quotation marks? Also, are there any extraneous spaces or tabs on the line? – Matt Johnson-Pint Feb 24 '14 at 17:15
  • I omitted the quotation marks (they were there in the first place) and nothing happened. Then I put them back and Voila! everything's working. I still have no idea what went wrong in the first place and how did I manage to fix it. Anyway, Matt, Michael, thanks for your time. I would live to accept both of your answers! – Zel Feb 24 '14 at 17:30
  • Perhaps you copied from somewhere that used fancy quotes (“ ”) instead of regular ones (" ") ? – Matt Johnson-Pint Feb 24 '14 at 18:37
  • Now, that's not only a plausible explanation to this little mystery but also an essential lesson to the copy-and-paste brigade (and God knows how hard am I trying to escape its iron clutches). Thanks for the closure, Matt. – Zel Feb 24 '14 at 22:40