2019-10-29 15:25:05 0 评论 Yii 2.0 Boy.Lee

Yii 2 使用 时间日期选择器(Datetime picker) Demo

 1  使用 git 或者 composer 下载类库 (https://github.com/kartik-v/yii2-widget-datetimepicker)

$ php composer.phar require kartik-v/yii2-widget-datetimepicker "*"

 

2. view code

use kartik\datetime\DateTimePicker;

<?= $form->field($model, 'u_expiredDate')->widget(DateTimePicker::className(), [
    'pluginOptions' => [
        'format' => 'yyyy-mm-dd hh:ii:ss',
        'autoclose' => true,
    ]     

]) ?>




<?= 
    DateTimePicker::widget([
        'model' => $model,
        'attribute' => 'aspl_actionDate',
        'options' => ['placeholder' => 'Please Select a Date'],
        'pluginOptions' => [
                'format' => 'yyyy-mm-dd hh:ii:ss',
        ]
    ]);

?>


<?= 
    DateTimePicker::widget([
        'name' => 'yiilib_datetime',
        'options' => ['placeholder' => 'Select operating time ...'],
        'convertFormat' => true,
        'pluginOptions' => [
            'format' => 'yyyy-mm-dd hh:ii:ss',
            'startDate' => '2019-01-01 12:12:12',
            'todayHighlight' => true
        ]
    ]);

?>