关于yii如何设置时区问题

小疑问当我php.ini没有设置

date.timezone = "Asia/Chongqing"

这样的时区时候,运行yii会有这样的报错

“date() [<a href='function.date'>function.date</a>]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 '8.0/no DST' instead”

解决的办法有

1》在php.ini 文件中添加

date.timezone = "Asia/Chongqing"

2》或者 php;中处理代码时候 需要  echo gmdate('Y-m-d H:m:s', time()+8*3600);

3》date_default_timezone_set("Asia/Shanghai");

问题1.

我想问一下yii的main.php文件中的数组

return array(

&#039;basePath&#039;=&gt;dirname(__FILE__).DIRECTORY_SEPARATOR.&#039;..&#039;,


&#039;name&#039;=&gt;&#039;blog&#039;,


&#039;defaultController&#039;=&gt;&#039;post&#039;,)

有没有关于时区的设置,效果如 date_default_timezone_set()

  1. 关于main.php数组中所有的参数有没有一篇完整的文章,可以统一介绍一下。若有请发一下连接,也许我没有找到其地址。

目前我看到现象是十分的零散。例如:当介绍URL Management 他才引出需要如下设置

'components'=>array(

        …

        'urlManager'=>array(

            'urlFormat'=>'path',

        ),

    ),

  1. 你可以在index.php或main.php头上加入设置时区的PHP代码。

  2. main.php里的参数是对CWebApplication的属性的配置(name=>value)。任何CWebApplication可写的属性都可以在main.php里配置。比如CWebApplication.setComponents()定义了'components'这个可写属性。具体到'components'里的取值,你需要看对应的API文档。比如'urlManager',它缺省用的是CUrlManager,所以你需要看CUrlManager有哪些可写的属性。

可以在config/main.php 里

return array(

'basePath'=&gt;dirname(__FILE__).DIRECTORY_SEPARATOR.'..',





'name'=&gt;'My Web ',





    'timeZone'=&gt;'Asia/Chongqing',





// preloading 'log' component


'preload'=&gt;array('log'),

设定时区.