ana-lu
ana-lu

Reputation: 379

Error with date.timezone in php.ini

I'm trying to install a Symfony project on a new mac and I keep having this ErrorExeception:

[ErrorException] 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone.

  1. I have already verified my PHP version using phpinfo();.
  2. The path for my php.ini is /Applications/MAMP/bin/php/php5.5.10/conf
  3. I opened my php.ini and I changed the date.timezone to date.timezone = "Europe/Paris"
  4. I restarted my MAMP many times and I keep having the same Error
  5. I also noticed that I have a php.ini.temp in the same folder. I also changed the date.timezone in this file but it still doesn't work.

Does anyone have an idea about what is happening?

Thanks!

Upvotes: 1

Views: 5905

Answers (4)

Harish ST
Harish ST

Reputation: 1503

I was installing Sylius and got into this similar issue. I have changed the timezone in the php.ini which I got from phpinfo() script. The configuration file location was: /etc/php/7.4/fpm/php.ini

Even after that, Sylius install reported the same issue. So, I followed the below steps.

Ran php -i | grep timezone:

Default timezone => Asia/Calcutta
date.timezone => no value => no value

Ran php -i | grep php.ini:

Configuration File (php.ini) Path => /etc/php/7.4/cli
Loaded Configuration File => /etc/php/7.4/cli/php.ini

After updating the value in the above CLI config file, everything went smooth.

Upvotes: 0

fernão lopes
fernão lopes

Reputation: 9

Symfony uses php command line (CLI) to make the install, so editing /etc/php5/apache2/php.ini will make no effect.

Try editing php-cli config. On debian:

vim /etc/php5/cli/php.ini
date.timezone = "Europe/Paris"

/etc/init.d/apache2 restart

Upvotes: 0

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111829

You should simple add to your Symfony controller :

phpinfo();

and you will know where your php.ini is located and you should make sure you changed value in this file.

You should also consider setting timezone in your script:

date_default_timezone_set('Europe/Paris');

because you (or someone else) may simple change it in future to other timezone

Upvotes: 1

Alex
Alex

Reputation: 1573

$ su root

Enter root password

$ vim /etc/php.ini

Edit the timezone in this file

Upvotes: -1

Related Questions