Reputation: 51
I'm trying to run new symfony project by symfony new name_project 2.7.21. Unfortunately, I keep having the error for incorrect time zone. I changed it in my C:\xampp\php\php.ini file. Do I have to change it somewhere else? Many thanks for your help
Upvotes: 5
Views: 14165
Reputation: 71
If your Symfony version is "^4.*" you can set your global timeZone in project/public/index.php
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
date_default_timezone_set( 'Europe/Moscow' );
$request = Request::createFromGlobals();
PHP supported timezone list below
https://www.php.net/manual/en/timezones.europe.php
Upvotes: 5
Reputation: 775
Ubuntu
Though I had date.timezone set in the /etc/php5/apache2/php.ini file.
I had to Set the date.timezone = "Asia/Calcutta" in the php.ini file which was in the cli directory.
/etc/php5/cli/php.ini
This solved it for me...
Upvotes: 2
Reputation: 863
Hey so I spent a lot of time chasing this down so here's what worked. To find the real php.ini that you need to change go to Terminal and run the following:
php -i | grep "php.ini"
You'll get a path like this: Configuration File (php.ini) Path => /etc
When you go to that directory you may find that you, in fact, have no php.ini
file at all but instead have something named php.ini.default
!!!
Copy that bad boy in Terminal like so: sudo cp php.ini.default php.ini
Then open up your new php.ini
file and edit the date.timezone = "Europe/Paris"
IMPORTANT!!! RESTART YOUR LOCAL SERVER!
Then go back to Terminal and run Symfony's complaining-ass validator like so: php my_project_name/bin/symfony_requirements
Upvotes: 0
Reputation: 2302
try
add in app/AppKernel.php
public function __construct($environment, $debug)
{
date_default_timezone_set( 'Europe/Warsaw' );
parent::__construct($environment, $debug);
}
I had the same problem with CI system , and that was solution
Upvotes: 6
Reputation: 557
If editing the ini file doesn't work, make sure you are editing the correct one. Check which ini file php is loading by outputting the phpinfo
results.
Otherwise, you can hard-code the timezone in app.php
and app_dev.php
See: http://php.net/manual/en/function.date-default-timezone-set.php
Upvotes: 0