1

I have creating form fields. Here, i want to add DateTimePicker.

I have referred in google about some date time picker. i got so many.

DateTimePicker jQuery plugin
Bootstrap DateTimePicker.

My question is which plugin is best among them. and

How can i install that plugin?

  1. Download directory and place where?

  2. Install via cmd.?

Chinmay Waghmare
  • 5,368
  • 2
  • 43
  • 68
Deen
  • 611
  • 2
  • 16
  • 30

2 Answers2

0

You don't need to use jquery plugin for that. Yii2 has several widgets which you can use: Some of them are:

1) Yii2 Jui DatePicker 2) Kartik yii2-widget-datepicker 3) 2amigos yii2-date-picker-widget

You can use anyone of these.

Chinmay Waghmare
  • 5,368
  • 2
  • 43
  • 68
0

You need to install or update your composer.
If you are using Ubuntu or Linux Operating System, open command prompt and run this command: composer require --prefer-dist yiisoft/yii2-jui
This will create the jui folder which contains all the required plugins such as datepicker or any other you want to use in your website. Now you just have to place this code in your form.php in views folder

use yii\jui\DatePicker;
<?= $form->field($model, 'from_date')->widget(\yii\jui\DatePicker::classname(), [
    //'language' => 'ru',
    'dateFormat' => 'MM-dd-yyyy',
    ]) ?>