MAMP / PHP.INI: the date.timezone parameter in phpinfo () shows "no value", even if the value is set in php.ini

Welcome StackOverflow Guru!

Here's the problem I'm struggling with.

I run phpinfo () in MAMP, and the resulting table shows "no value" in both columns of the date.timezone row.

In addition, the page displays the following:

Warning: phpinfo () [function.phpinfo]: You cannot rely on the system time zone settings. You must use the date.timezone parameter or the date_default_timezone_set () function. If you used any of these methods and you still get this warning, most likely you are mistaken with the time zone identifier. We chose 'America / New_York' instead of 'EST / -5.0 / no DST' instead of /Applications/MAMP/bin/mamp/phpinfo.php

However, in the phr.ini thr file, the parameter is as follows:

date.timezone = America / New_York

I foresee a recommendation to check the correct path to php.ini - I already did this, and the path is really correct: /Applications/MAMP/conf/php5.3/php.ini - this is an IS file with the value set.

How can I fix this problem? What am I missing?

I would be grateful for the help from a knowledgeable person.

+8
php mamp
source share
6 answers

If the time zone is set correctly in the corresponding php.ini file and you still get this message, you can try setting the TZ environment variable. Modify your .profile to add the following line (sub in your own timezone line ):

export TZ="America/New_York" 

Not sure why (a) MAMP overrides your php.ini parameter, (b) PHP does not throw a notification / warning when using the env TZ variable, although it says it will, but this solution worked for me using MAMP 2.0.5 with PHP 5.3.6.

+5
source share

I know that I may be a little late in answering this, but I see on several sites that you specify to set the correct time zone in MAMP.

It should be noted that for the php file, there are two locations for the php.ini file. MAMP can load it from a different path than the one you are editing.

For example, let's say we use php 5.3. Here are two php.ini file locations that can confuse someone that you can edit.

 /Applications/MAMP/bin/php/php5.3/conf/php.ini 

It seems you are editing it in this place below:

 /Applications/MAMP/conf/php5.3/php.ini 

Editing the time zone in the second way did not work for me, but editing what was in the first. You may be editing the wrong file, although it looks the same. I tested this on my version. Running <?php phpinfo(); ?> <?php phpinfo(); ?> in the php file and checking the path to the php.ini file will always show the correct path.

It is also easy to specify using double quotes around the date.timezone value will work. For example, the following works in my php.ini file.

 date.timezone = "America/Vancouver" 

Also, the default value was enclosed in double quotes.

I also used MAMP version 2.1.1 when testing this.

+8
source share

Note that there are different versions of PHP in / Applications / MAMP / conf . You should check which version you use in MAMP -> Preferences -> Tab "PHP"

If set to 5.4.4, you must access /Applications/MAMP/conf/php5.4.4/php.ini

@edit

Run in terminal:

 sed -i '$ a\date.timezone = "America/New_York"' /Application/MAMP/conf/php{5.4.4,5.2.17,5.3.13,5.3.14,5.3.5,5.4.3}/php.ini 

or

 sed -i 's/date.timezone = "Europe/Berlin"/date.timezone = "America/New_York"/g' /Application/MAMP/conf/php{5.4.4,5.2.17,5.3.13,5.3.14,5.3.5,5.4.3}/php.ini 
+3
source share

If this error is detected using the CLI of the terminal CLI, it could be a conflict with the internal and MAMP server.

MacOS X comes with a pre-installed version of PHP and what works in the shell when php entered. The MAMP PHP configuration is separate from the predefined PHP configuration: changing the MAMP PHP timezone setting does not affect what you see in the CLI - hence, the timezone error persists. A quick way to check is to run which php — if you don't see the path starting with /Applications/MAMP/... , you need to set up the environment.

To do this, edit the text file .profile (or bash RC file) and add the following line to it:

 export PATH="/Applications/MAMP/bin/php5.5.3/bin:$PATH" 

Adjust the above path to point to the desired MAMP PHP installation. Then run:

 . ~/.profile hash -r 

This will apply the PATH change immediately (otherwise you will need to open a new terminal window to apply the changes). The second command is the CLI> cleanup command.

As a final check, run which php to check which PHP installation path is being used. Hope this helps!

+3
source share

In Ubuntu 13.10 using php 5.5.3 open a terminal and do

 cd / sudo find -name php.ini 

it shows two php.ini files for me:

  ./etc/php5/apache2/php.ini ./etc/php5/cli/php.ini 

open both files using sudo i use nano

 sudo nano /etc/php5/apache2/php.ini 

find and edit this line:

 ;date.timezone = 

and change to:

 date.timezone = America/Caracas 

Save and close this file and edit another

 sudo nano /etc/php5/cli/php.ini 

find and edit this line:

 ;date.timezone = 

and change to:

 date.timezone = America/Caracas 

Save and close and restart apache with

 sudo service apache2 restart 

It works for me !!!

+1
source share

grep -lr "Berlin" * | xargs sed -i .backup -e 's#Europe/Berlin#America/New_York#g'

The above command required some refinement in my case. It will also create backup files.

0
source share

All Articles