Symfony2 and date_default_timezone_get() - It is not safe to rely on the system's timezone settings
Maybe you are trying to set it in Apache's php.ini
, but your CLI (Command Line Interface) php.ini
is not good.
Find your php.ini
file with the following command:
php -i | grep php.ini
And then search for date.timezone
and set it to "Europe/Amsterdam"
. all valid timezone will be found here http://php.net/manual/en/timezones.php
Another way (if the other does not work), search for the file AppKernel.php
, which should be under the folder app
of your Symfony project directory. Overwrite the __construct
function below in the class AppKernel
:
<?php
class AppKernel extends Kernel
{
// Other methods and variables
// Append this init function below
public function __construct($environment, $debug)
{
date_default_timezone_set( 'Europe/Paris' );
parent::__construct($environment, $debug);
}
}
date_default_timezone_get(): It is not safe to rely on the system's timezone settings
Default php.ini
in OS X is located at:
/private/etc/php.ini
Anyway, you'll can either tell CLI php to load MAMP settings, or use an alias of MAMP command itself.
Acme Bundle Installation error: Warning it is not safe to rely on the system's timezone settings
You need to set the parameter date.timezone
in your php.ini for every valid timezone and after that do not forget to restart Apache, try if this solve your issue
Procedure
I'm not use LAMP environment since I work with Linux but things should be the same as Mac is *nix. Anyway, you should find where php.ini
file is under your directory structure (again I not use MacOS so I can't help here) and open it with any text editor or console text editor (personally I prefer this one) and find for that string date.timezone
when you found it just uncomment that line by removing the ;
symbol at front of the string and add a valid timezone lets said for example Europe/Amsterdam
then you should have something like:
date.timezone = Europe/Amsterdam
That's all, restart your LAMP environment if you use any stack application or just restart Apache service, that will be all
Symfony 2.7: default timezone not set, causing fatal error
it is recommended that you set the timezone in php.ini but if you are in shared environment or if you don't have access to it for some reason you can add this in app/AppKernel.php
class AppKernel extends Kernel
{
public function __construct($environment, $debug)
{
date_default_timezone_set( 'America/Detroit' );
parent::__construct($environment, $debug);
}
}
Related Topics
Laravel Multiple Pagination in One Page
PHP Form Send Email to Multiple Recipients
How to Call Codeigniter Controller Function from View
How to Send Emails via Cron Job Usng PHP MySQL
Read a File Backwards Line by Line Using Fseek
Selecting Multiple Array Elements
Getting a Modified Preorder Tree Traversal Model (Nested Set) into a <Ul>
How to Efficiently Find the Closest Locations Nearby a Given Location
How to Get PHP to Produce a Backtrace Upon Errors
PHP - Remove <Img> Tag from String
Php. How to Use Array_Column with an Array of Objects
Resize Images in PHP Without Using Third-Party Libraries
Warning: MySQLi_Error() Expects Exactly 1 Parameter, 0 Given Error