Prevent date_default_timezone_get() warning in Symfony2

Prevent date_default_timezone_get() warning in Symfony2

Hi,

For those who had this kind of problem when using Symfony2:

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

just add this to app/AppKernel.php

1
2
3
4
5
6
7
8
9
class AppKernel extends Kernel
{
    public function init()
    {
        date_default_timezone_set('Europe/London');
    }

    // rest of your code...
}