Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timezone in symfony

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

like image 364
aggie29 Avatar asked Dec 09 '16 18:12

aggie29


2 Answers

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

like image 148
Michał G Avatar answered Nov 04 '22 18:11

Michał G


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

like image 44
Tigran Paremuzyan Avatar answered Nov 04 '22 19:11

Tigran Paremuzyan