1

So I installed composer and apache and mysql, and then installed symfony, but after the installation it tells me to change the date because it is not reliable and then I can use it freely.

I have changed the date in php.ini with Europe/Bucharest but is still get this message:

[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. 

I use fedora 23 32-bit.I have looked over other solutions but none of them work.

Schneejäger
  • 231
  • 3
  • 15
  • Did you restarted Apache? Please add in your question the configuration you added in `php.ini`. – A.L Feb 17 '16 at 12:22
  • Restart your server and have a look on http://stackoverflow.com/questions/13595942/mamp-symfony-mamp-overrides-date-timezone-setting-from-php-ini-symfony-fails – safin chacko Feb 17 '16 at 12:31
  • I have restarted the Apache server, did change the php.ini with vi like ( http://stackoverflow.com/questions/13595942/mamp-symfony-mamp-overrides-date-timezone-setting-from-php-ini-symfony-fails ) and nothing changed, the same error – Schneejäger Feb 17 '16 at 14:02

2 Answers2

5

In Symfony2 just add this at the end of your class app/AppKernel.php :

public function init() {
    date_default_timezone_set( 'Europe/Bucharest' );
    parent::init();
}

In Symfony3, use :

public function __construct($environment, $debug) {
    date_default_timezone_set('Europe/Bucharest');
    parent::__construct($environment, $debug);
}
  • I added it, it took him a moment and told me the same thing, should i reinstall or something? new to symfony. – Schneejäger Feb 17 '16 at 14:11
  • It always worked fine for me, are you sure you picked the right version and added between the braces of the class AppKernel ? – Aymeric Wilke Feb 17 '16 at 14:14
  • Yes i did try both of them. i will check again to see if it is between the braces. – Schneejäger Feb 17 '16 at 15:48
  • got this now, after i verified and modified a bit PHP Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /home/m80/my_project/app/AppKernel.php on line 28 – Schneejäger Feb 17 '16 at 16:00
  • I think you forgot to close a brace somewhere in your file, or something like that – Aymeric Wilke Feb 17 '16 at 18:21
  • [Symfony\Component\Debug\Exception\ContextErrorException] Warning: Invalid argument supplied for foreach() This is the error that gives now, from one thing to another. Sorry for being such a newbie. – Schneejäger Feb 17 '16 at 19:52
  • Try to verify everything in your file, like quotes, end of lines, etc. And maybe delete your folders in your cache directory, … – Aymeric Wilke Feb 18 '16 at 10:57
0
public function __construct($environment, $debug)
{
    parent::__construct($environment, $debug);
    date_default_timezone_set('Asia/Shanghai');
}

I use this in symphony 2.3

Simon
  • 226
  • 2
  • 6