Timezone Error

Update: Check out our new Yii2 Developer Exchange site at http://yii2x.com. It’s devoted exclusively for Yii2 developers to make it easier to find news, tips, tutorials and extensions related to Yii2.

If you receive the following timezone settings error when trying to migrate your database for the first time:

PHP Error[2]: 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone.
    in file /Users/Jeff/Sites/ocean/app/protected/modules/user/models/User.php at line 63

I’ve found that the most effective fix in your local development environment is to add the date_default_timezone_set line to your /app/protected/yiic.php file:

< ?php

// change the following paths if necessary
$yiic=dirname(__FILE__).'/../../framework/yiic.php';
$config=dirname(__FILE__).'/config/console.php';
date_default_timezone_set("America/Los_Angeles");
require_once($yiic);

Leave a reply

Your email address will not be published. Required fields are marked *