yii2-datepicker/datetimepicker插件使用
生活随笔
收集整理的這篇文章主要介紹了
yii2-datepicker/datetimepicker插件使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
datepicker:
https://github.com/2amigos/yii2-date-picker-widget
通過composer安裝:
使用方法:
<?php use dosamigos\datepicker\DatePicker;// as a widget ?><?= DatePicker::widget(['model' => $model,'attribute' => 'date','template' => '{addon}{input}','clientOptions' => ['autoclose' => true,'format' => 'dd-M-yyyy'] ]);?><?php // with an ActiveForm instance ?> <?= $form->field($model, 'date')->widget(DatePicker::className(), [// inline too, not bad'inline' => true, // modify template for custom rendering'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>','clientOptions' => ['autoclose' => true,'format' => 'dd-M-yyyy'] ]);?>datetimepicker:
http://www.yiiframework.com/extension/yii2-datetimepicker-widget/
通過composer安裝:
使用方法:
<?php use dosamigos\datetimepicker\DateTimePicker; // as a widget ?> <?= DateTimePicker::widget(['model' => $model,'attribute' => 'created_at','language' => 'es','size' => 'ms','clientOptions' => ['autoclose' => true,'format' => 'dd MM yyyy - HH:ii P','todayBtn' => true] ]);?> <?= DateTimePicker::widget(['id' => 'test1','name' => 'test1',//當沒有設置model時和attribute時必須設置name'language' => 'es','size' => 'ms','clientOptions' => ['autoclose' => true,'format' => 'dd MM yyyy - HH:ii P','todayBtn' => true] ]);?> <?php // with an ActiveForm instance displayed as a TimePicker use dosamigos\datetimepicker\DateTimePicker; ?> <?= $form->field($tour, 'date_from')->widget(DateTimePicker::className(), ['language' => 'es','size' => 'ms','template' => '{input}','pickButtonIcon' => 'glyphicon glyphicon-time','inline' => true,'clientOptions' => ['startView' => 1,'minView' => 0,'maxView' => 1,'autoclose' => true,'linkFormat' => 'HH:ii P', // if inline = true// 'format' => 'HH:ii P', // if inline = false'todayBtn' => true] ]);?>版權聲明:本文為博主原創文章,未經博主允許不得轉載。
轉載于:https://www.cnblogs.com/faraway-tiny/p/4918356.html
總結
以上是生活随笔為你收集整理的yii2-datepicker/datetimepicker插件使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 暑期训练狂刷系列——Foj 1894
- 下一篇: c#中跨线程调用windows窗体控件