Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Uncaught exception with message date() - unsafe to rely on systems timezone
  • When running 'oil create <project name>' or 'oil refine install' it will generate the following error:

    "Fatal error: Uncaught exception 'Fuel\Core\PhpErrorException' with message 'date(): 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 'UTC' for 'GMT/0.0/no DST' instead' in "

    I understand this is a local error with my environment but I never had this before and just wanting to know what changed from 1.3 that would cause it to be behave this way and what you'd suggest to fix this.


    Regards,
    Jamie
  • Check the release notes, it was mentioned at the top, in bold.

    1.3 had a default setting to UTC, which nobody checked, and caused all kinds of misery when the server wasn't running in UTC (most notably failing sessions).

    So for 1.4 it was removed, forcing you to configure it properly.
  • Updated my php.ini file to the following and it still has the same error..

    [Date]
    ; Defines the default timezone used by the date functions
    ; Will be changed by MAMP to system timezone
    date.timezone = "Europe/London"
    date.default_latitude = 51.500181
    date.default_longitude = -0.12619

    I added the following also to the config, and oil will work after I do this, but a simple oil create projectname will not, just gives me all the errors about timezones..

    return array(
        'default_timezone' => 'Europe/London',
    );

  • When using xAMP installations, you have to make sure both apache and the CLI uses the same php.ini, because by default they don't, causing all kinds of weird errors.
  • I'm still having an issue with 1.4.

    I use MAMP and run Mountain Lion. I have the correct php.ini file loaded as I can change the date.timezone to "Europe/London" to something else and I can see the change on a restart via phpinfo() function.

    Hopefully someone can help.

    CLI keeps giving me the following error:
    [quote]Fatal error: Uncaught exception 'Fuel\Core\PhpErrorException' with message 'date(): 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 'UTC' for 'GMT/0.0/no DST' instead'[/quote]

    Hopefully someone has had this issue and can resolve it. Everything seems to be linked up and working fine!
  • You also have to configure your (= the same as your server and php.ini) timezone in app/config/config.php.
  • Yeah. I did that and then oil works, but the oil create <name> errors out, I mean it's no big deal, I can still add in the app/config/config.php my timezone and then go back to fuel to continue the install to make files writeable etc.

    Just annoying me it's not fully working like oil was before when creating a project.
  • Just a sec, I just noticed you wrote MAMP.

    MAMP is notorious for it's crappy setup. It is most likely that your CLI version of PHP uses is different version of php.ini then your webserver does.

    I already found it weird, since that error message is generated by PHP, not by the framework.

    This is a similar issue: http://fuelphp.com/docs/installation/troubleshooting.html#/oil_db_error
  • Solution:

    create a php.ini in /etc (with the right date.timezone='xxxxx' setting)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion