I'm getting an error whilst using php + smarty on my mac running mavericks.
I've read in several places that you must change the timezone settings in the php.ini files.
i've also run the command to see which file php is pointing to:
php -i | grep 'Configuration File'
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
After that i changed the date.timezone line to the following...
date.timezone = "Australia/Sydney"
and this was done in the files
/etc/php.ini
/etc/php.ini-5.2-previous
/etc/php.ini.default
The error is as follows...
Warning: strftime(): 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 /Library/Smarty3.1.16/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 234
For those who are still wondering.
Similarly, in my case, Yosemite OS, I had no php.ini file in /etc. So I copied /etc/php.ini.default and modified it by adding a timezone and removing ;
$ sudo cp /etc/php.ini.default /etc/php.ini
And then:
date.timezone = America/Los_Angeles
Related
I'm using MAMP for Windows 10 , and I have a problem when I try to make a project with symfony. I install symfony with the installer and when I launch the command "php symfony new my_project_name", the installation doesn't work because of a time zone error.
To find the php.ini, I launch the php info on MAMP and it displays this
"Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File C:\MAMP\conf\php5.6.3\php.ini "
and I checked on apache con (C:\MAMP\conf\apache\httpd.conf) for PHPIniDir : PHPIniDir "C:\MAMP\conf\php5.6.3\php.ini"
I modify the timezone parameter as follows
[Date]
; Defines the default timezone used by the date functions
date.timezone = Europe/Paris
and I launch the check but it seems that I didn't modify the right file. Also, there is a problem with my php.in; the following errors occur
Symfony2 Requirements Checker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> Checking Symfony requirements:
.....E................W...WW.W.....
[ERROR]
Your system is not ready to run Symfony2 projects
Fix the following mandatory requirements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* date.timezone setting must be set
> Set the "date.timezone" setting in php.ini* (like Europe/Paris).
Usually, the PHP CLI uses a different php.ini configuration than the Apache PHP. Could you check where is the right configuration file for command line? This topic can help you.
Then when you'll find it, just do the same as you did with the MAMP php.ini. It should work.
Find PHP.INI file for CLI like this:
hp -i |grep php.ini
and then modify date.timezone in it. Voila! It worked for me.
I installed MAMP for windows
I have this error since several hours...
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: 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 me
thods and you are still getting this warning, you most likely misspelled th
e timezone identifier. We selected the timezone 'UTC' for now, but please s
et date.timezone to select your timezone.
In the php.ini concerned (C:/MAMP/conf/php5.5.19/php.ini), I changed the line DATE like this:
[Date]
; Defines the default timezone used by the date functions
date.timezone = "Europe/Paris"
And in my phpinfo(), the path loaded is :
Loaded Configuration File C:\MAMP\conf\php5.5.19\php.ini
When I do in the consol the command php --ini I have this :
C:\Users\Thomas>php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Why Configuration File (php.ini) Path: is "C:\Windows" and not C:\MAMP\conf\php5.5.19\. Can I change this Path ?
I don't know what to do now...
thanks !
I had the same error. I had no clue where it was coming from, but with some trial and error I figured out it had something to do with the special character in my htdocs folder:
htdocs/Exámple
By changing that character to a normal character (thus changing to htdocs/Example), I no longer got the error and the site would load normally.
The problem is that your xAMP server and cli access uses different php configuration.
One is C:\Windows\php.ini for CLI
Second is C:\MAMP\conf\php5.5.19\php.ini for web server
Make sure you have updated both files.
Secondly do not forget to restart xAMP server, as apache do not reload libapache2-mod-php5 configs automatically.
When you set configuration in MAMP it only affects PHP which is loaded in Apache module handler mode (mapped as module inside Apache process). If you want to set PHP CLI you need to set this separately from web server configuration.
Open command prompt from Windows (cmd.exe from Start button)
enter ECHO %PATH%
this command will list your current PATH variable with all paths. For example, something like this:
C:>echo %PATH%
C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\binaries\php\php_runningversion
;C:\ProgramData\Oracle\Java\javapath;C:\Perl\site\bin;C:\Perl\bin
...
now enter following command
SET PATH=%PATH%;c:\mamp\bin\php\php5.6.0\;
This will going to add path to php5.6.0 version from MAMP folder.
you can now test your PHP CLI by entering following command :
php -v
then try to initialize configuration from MAMP for version PHP5.6.0 file:
C:>php -c "c:\mamp\conf\php5.6.0\php.ini" --ini
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: C:\MAMP\conf\php5.6.0\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
You can use command -c from PHP CLI to set path to configuration file; and "c:\mamp\conf\php5.6.0\php.ini" is path to PHP ini file for version 5.6.0.
If you do not want to always add path to configuration file with -c command, just copy php.ini file from C:\MAMP\conf\php5.6.0\ to C:\MAMP\bin\php\php5.6.0\
Off course, this will going to set PHP CLI only in currently opened command prompt. To add this path permanently, you need to modify System Environment variable, or to use MAMP PRO as it already have this feature on PHP options page.
TL:DR - Make sure to edit both the ..\MAMPPRO\conf\php[version].ini and the ..\MAMP\bin\php\php[version]\php.ini with your correct/approved php timezone.
So while I was going through my setup, I had the same issue.
I was taking a look at my phpinfo() and it was giving me a path to my "Loaded Configuration File" that was located in my ..\MAMPPRO\conf\php[version].ini so I was editing that file with approved timezone from http://php.net/manual/en/timezones.php making sure to avoid any from http://php.net/manual/en/timezones.others.php.
After a few restarts and no success I started to dig a little further into where MAMP Pro was pulling that ini.
I found the solution in ..\MAMP\bin\php\php[version]\php.ini. If I edited this file IN ADDITION TO editing the MAMP Pro ini everything worked properly.
Hopefully this can help you out!
At the beggining of your web/app_dev.php and web/app.php you can add:
date_default_timezone_set('Europe/Paris');
I set up a new environment using OSX Yosemite.
I'm using the built-in PHP.
I'd like to change some config in php.ini such as date.timezone but none of the modifications are working despite restarting the apache server (sudo apachectl restart).
phpinfo() is giving a different path than php --ini command.
phpinfo():
Configuration File (php.ini) Path /usr/local/php5/lib
Loaded Configuration File /usr/local/php5/lib/php.ini
Via commands :
which php
/usr/bin/php
php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed: (none)
So I guess I have to tell somewhere where I should set the default php.ini to be used.
Any ideas, hints?
move the configuration file to the right spot and update the timezone.
$ sudo cp /etc/php.ini.default /etc/php.ini
Open the config file /etc/php.ini, find the line that sets your timezone and update it correspondingly.
date.timezone = Europe/Berlin
Do not forget to remove the ; at the beginning.
Restart the Apache server to have PHP load the new .ini file.
sudo apachectl restart
SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)
http://php.net/manual/en/configuration.file.php
Try changing PHPIniDir in httpd.conf.
On mac sierra with php7.1, edit /usr/local/etc/php/7.1/php.ini won't work, you can edit like this:
1) cp /etc/php.ini.default php.ini
2) edit php.ini to add
date.timezone = Europe/Berlin
then restart your apache,
Short answer: If you're on mac and you have the file /usr/local/php5/php.d/99-liip-developer.ini then edit timezone there and it will effect php-cgi (web-browser)
Long answer:
n mac system for few settings like timezone php.ini file (showing loaded in phpinfo) don't work. Because sometimes we unknowingly install php packaged by Liip. That's why apache picks up few settings from liip-developer.ini config file which is usually located at /usr/local/php5/php.d/99-liip-developer.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.
I have already verified my PHP version using phpinfo();.
The path for my php.ini is /Applications/MAMP/bin/php/php5.5.10/conf
I opened my php.ini and I changed the date.timezone to date.timezone = "Europe/Paris"
I restarted my MAMP many times and I keep having the same Error
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!
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
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
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.
$ su root
Enter root password
$ vim /etc/php.ini
Edit the timezone in this file
I have the following problem. I am getting this warning on my php page on my localhost
Message: date() [function.date]: It is not safe to rely on the system's timezone settings.
I am trying to edit my php.ini file. When i use phpinfo() php function it show that php.ini file is in /etc folder. However, there I have no php.ini file. I have php.in, php.ini-5.2-previous,php.ini.applesaved,php.ini.default,php.ini.default-5.2-previous, but no php.ini
In all those files I enter the following command:date.timezone = Europe/Athens
I try with quotes, without quotes...with single quotes...Nothing. I restart apache after each change, nothing...I restart the computer twice, same story.
Anyone can help with this? Please note that I want to solve this only with adding this command in php.ini
Regards, Zoran
Mac OS X Lion moves your php.ini to php.ini.applesaved.
You have to recreate your php.ini from php.ini.default or from php.ini.applesaved.
Copy your default php to a new file, and customize the timezone in there
sudo cp /etc/php.ini.default /etc/php.ini