Closed ShNURoK42 closed 11 years ago
Duplicate of #208
Not entirely sure if it is a duplicate. Seems like the console app causes an error before it even starts executing the app command?
date_default_timezone_set('UTC');
should be done in index.php
or php.ini
. That's common PHP 5.3+ requirement.
Renamed and reopened.
As I see this... This is not a requirement for a PHP script but a requirement for a PHP setup... this error means that the option date.timezone
in your (developer) PHP.INI is not set.
@mdomba yes. PHP script can correct it. The question is should we correct it or not.
Of course correct it. It will be cheaper than to explain all about the ini setting.
I think I remember a discussion about setting timezone to utc by default anyways...
//EDIT: Here it is: http://www.yiiframework.com/forum/index.php/topic/34055-components-datetime-and-ar/
If I setup my server (php.ini) on my timezone... than I would certainly not like to have Yii change this by default.
How about checking if it is set or not. If not, set it to UTC?
Yes, I think that's the way to go.
I think maybe add in entry point commented line with timezone set? so it will be a notice for user, and will not change defaults as @mdomba pointed to avoid unexpected behavior?
I think we're doing duplicate work.
There's already Application::getTimeZone() / Application::setTimeZone(). If Application::__construct cared for calling
$this->setTimeZone( ArrayHelper::remove($config,'timeZone','UTC') );
like it does with setBasePath(), everything should be fine. (Notice the use of our brand new, amazingly handy helper! :wink: ).
// EDIT: No wait. This is not what we want...
// EDIT 2: We need to know if the option is set or not.
if (isset($config['timeZone']) || !ini_get('date.timezone')) {
$this->setTimeZone( ArrayHelper::remove($config,'timeZone','UTC') );
}
Yeah, because this code in index.php not help with install a new application.
@bwoester what exactly do you suggest? Putting the code you've provided into index.php
?
@ShNURoK42 what do you mean?
When use yiic.php to install app, it call yii\logging\Logger init(), where call function date() This leads to exception unless defined time zone. In the first post I wrote about it.
I think https://github.com/yiisoft/yii2/commit/810d232ee6717f14f5ecfc4b7b7486ac4d199f26 is fine. It's meant to fix the problem that ideally should be fixed by the user.
Setting timezone via app config is another thing.
@ShNURoK42 fixed.
@samdark thanks!
Oops, I've been a little bit too slow on this, I guess. ^^
I use the Open Server. To install a new application I'm using its version php. Open Server has a "pending" php.ini config option and therefore the following error occurs.
I use hook and set date_default_timezone_set('UTC'); in yii\logging\Logger in init() method. Sorry for my bad English :)