The preferred way to install this extension is through composer.
Add
"mitalcoi/yii2-datetime-widgets" : "dev-master"
to the require section of your application's composer.json
file.
Demo from the bootstrap-datepicker plugin website.
use mitalcoi\widgets\DatePicker;
<?= $form->field($model, 'attribute')->widget(DatePicker::className(), [
'options' => ['class' => 'form-control'],
'clientOptions' => [
'format' => 'dd.mm.yyyy',
'language' => 'ru',
'autoclose' => true,
'todayHighlight' => true,
],
]) ?>
For more details, please check the bootstrap-datepicker plugin website.
Demo from the bootstrap-datetimepicker plugin website.
use mitalcoi\widgets\DateTimePicker;
<?= $form->field($model, 'attribute')->widget(DateTimePicker::className(), [
'options' => ['class' => 'form-control'],
'clientOptions' => [
'format' => 'dd.mm.yyyy hh:ii',
'language' => 'ru',
'autoclose' => true,
],
]) ?>
For more details, please check the bootstrap-datetimepicker plugin website.
Demo from the bootstrap-daterangepicker plugin website.
use mitalcoi\widgets\DateRangePicker;
<?= $form->field($model, 'actual_time')->widget(DateRangePicker::className(), [
'options' => ['class' => 'form-control'],
'clientOptions' => [
'ranges' => [
'Today' => [
new JsExpression('moment()'),
new JsExpression('moment()'),
],
'Yesterday' => [
new JsExpression('moment().subtract("days", 1)'),
new JsExpression('moment().subtract("days", 1)'),
],
],
'format' => 'DD.MM.YYYY',
'separator' => ' - ',
],
]) ?>
For more details, please check the bootstrap-daterangepicker plugin repo.