Timezone with symfony 2

I have problems with Symfony 2 that try to generate a circuit via:

php console/app generate:schema:create 

I have a pretty pretty error:

 [Exception] DateTime::__construct(): It is not safe to rely on the system 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 'Europe/Berlin' for 'CEST/2.0/DST' instead 

Thus, I am trying to change the time zone in my php.ini using

 date.timezone = 'Europe/Paris' 

but even if I restart my apache, I still get

 date.timezone Europe/Zurich Europe/Zurich 

if I look at my phpinfo() , so I don’t know what to do next ... And I'm not even sure that I am going in a good way.

Thank you for helping me.

+7
source share
9 answers

On mac, if you have /etc/php.ini.default , do

 sudo cp /etc/php.ini.default /etc/php.ini 

and then do

 php --ini 

to see that it is loading the php.ini file.

+16
source

this trick

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

datetime = 'America/Lima' for example

and run the command

 $ sudo apt-get install php5-sqlite $ sudo /etc/init.d/apache2 restart 
+2
source

Some third-party PHP distributions (including MAMP) have a hard-coded time zone. For example, MAMP 2.0 is hardcoded to Europe / Berlin, and there is no way to change this. Even changing the value in the php.ini template is not affected, because MAMP overwrites your value. Are you using PHP from source code, a pre-compiled package, or PHP as part of any LAMP stack?

+1
source

If you are running debian, you must change the parameter in the / etc / php 5 / cli / php.ini file, and changing it in / etc / php 5 / apache2 / php.ini is not affected.

+1
source

I know this is an old ticket, but since I also had a problem with this and it is still open, I thought I would share my quick dirty decision:

In my case, date.default not installed at all, and I was unable to modify php.ini . So, as a stop, I added date_default_timezone_set('Europe/Dublin') at the beginning of web/app.php to change the timezone at runtime, which worked well for me.

If you use the console to run any commands, you may have to add a call to the top of this script.

0
source

On Windows, I installed XAMPP for the web server and downloaded PHP and installed it so that I can run symfony commands from the command line.

In this case, the php.ini file used when running the Symfony command is located in C:\Program Files(x86)\PHP\php.ini . You must have administrator rights to edit this file, so I ran Notepad ++ as an administrator and opened the file.

Find date.timezone and change it according to your time zone, for example. date.timezone = Africa/Nairobi . The time zone is listed on the php website, just search for php, timezones . No need to restart your computer or web server.

0
source

I ran into this problem with my shared host. they told me that I cannot change time zones via php.ini, but instead you can try .htaccess .

create .htaccess in the folder where Symfony is installed, and paste the following code into it:

 SetEnv TZ America/Sao_Paulo 

hope this helps.

amuses Luciano

0
source

I ran into this problem with XAMPP on Mac 10.11.5, PHP 5.6.8

My mistake: "Warning: date_default_timezone_get (): Invalid date.timezone" America / Los Angeles ","

I fixed this by finding the only problem - the missing underscore in the Los Angeles entry for my date.timezone PHP.ini setting.

0
source

Try this command:

sudo ln -s / usr / local / php5 / lib / php.ini / etc / php.ini

Mac in my case. First - config, second - do not change.

0
source