yii2mod / yii2-timezone
时区助手
1.0.3
2016-03-01 08:06 UTC
This package is not auto-updated.
Last update: 2024-09-14 17:42:42 UTC
README
Yii 2 的时区组件
安装
安装此扩展的首选方法是使用 composer.
运行以下命令之一:
php composer.phar require --prefer-dist yii2mod/yii2-timezone "*"
或者
"yii2mod/yii2-timezone": "*"
将以下内容添加到您的 composer.json 文件的 require 部分。
用法
目前不支持 firefox 和 edge 浏览器。
扩展安装后,只需将组件添加到您的配置文件中
'bootstrap' => [ 'timezone' ] ..... 'components' => [ 'timezone' => [ 'class' => 'yii2mod\timezone\Timezone', 'actionRoute' => '/site/timezone' //optional param - full path to page must be specified ], ]
然后在任何控制器中添加新的操作(默认为 SiteController)
public function actions() { return [ 'timezone' => [ 'class' => 'yii2mod\timezone\TimezoneAction', ], ]; }
配置完成后,您可以使用 Yii::$app->timezone->name
获取当前用户的时区。