企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## Yii2日期时间插件 datetimepicker https://github.com/kartik-v/yii2-widgets ### 插件安装 1. 推荐使用`composer`安装 ```php composer require kartik-v/yii2-widget-datetimepicker "*" ``` 2. 在`composer.json`文件中如下内容并执行`composer update` ··· "kartik-v/yii2-widget-datetimepicker": "*" ··· ### 使用插件 使用方法可以参见作者[GitHub地址](https://github.com/kartik-v/yii2-widget-datetimepicker) 1.直接调用,在视图文件中写入如下代码。 ```php <?php use kartik\datetime\DateTimePicker; ?> <?= DateTimePicker::widget([ 'name' => 'datetime_10', 'options' => ['placeholder' => 'Select operating time ...'], 'convertFormat' => true, 'pluginOptions' => [ 'format' => 'd-M-Y g:i A', 'startDate' => '01-Mar-2014 12:00 AM', 'todayHighlight' => true ] ]); ?> ``` 2. 结合ActiveForm表单组件使用 ```php <?php use kartik\datetime\DateTimePicker; ?> <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'created_at')->widget(DateTimePicker::classname(), [ 'options' => ['placeholder' => ''], 'pluginOptions' => [ 'autoclose' => true, 'format' => 'yyyy-mm-dd hh:ii', 'startDate' => '01-Mar-2014 12:00 AM', 'todayHighlight' => true ] ]); ?> <?php ActiveForm::end(); ?> ```