PHP code example of wattanapong / yii2-widget-datetimepicker
1. Go to this page and download the library: Download wattanapong/yii2-widget-datetimepicker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wattanapong / yii2-widget-datetimepicker example snippets
use wattanapong\datetime\DateTimePicker;
// usage without model
echo '<label>Check Issue Date</label>';
echo DateTimePicker::widget([
'name' => 'attributename',
'value' => date('d M Y', strtotime('+2 days')),
'options' => ['placeholder' => 'Select date ...'],
'pluginOptions' => [
'format' => 'dd-M-yyyy',
'todayHighlight' => true,
'isBE' => true,
'timeFormat' => 'hh:mm:ss',
'buttonImageOnly'=> true,
'maxDate' => date('d M Y',strtotime('+2 days')),
'minDate' => date('d M Y',strtotime('-10 days')),
]
]);
// usage with model
<?= $form->field($model, 'attributename')->widget(DateTimePicker::className(),
[
'dateFormat' => 'php:d M yy',
'isDateTime' => false,
'name' => 'attributename',
'value' => date('d M Y', strtotime('+2 days')),
'options' => ['class'=>'form-control','placeholder' => 'Select date ...'],
'pluginOptions' =>[
'isBE' => true,
'timeFormat' => 'hh:mm:ss',
'buttonImageOnly'=> true,
'maxDate' => date('d M Y',strtotime('+2 days')),
'minDate' => date('d M Y',strtotime('-10 days')),
]
]
)
use wattanapong\datetime\DateTimePicker;
// usage without model
echo '<label>Check Issue Date</label>';
echo DateTimePicker::widget([
//'model' => $modelTrainingCourse,
'from' => 'trainingdate',
'value' => date('d M Y'),
'to' => 'trainingend',
'valueTo' => date('d M Y', strtotime('+2 days')),
'dateFormat' => 'php:d M yy',
'isDateTime' => true,
//'separate' => 'To',
'options' => ['class'=>'form-control','placeholder' => 'Select date ...'],
'pluginOptions' =>[
'isBE' => true,
'timeFormat' => 'hh:mm:ss',
'showButtonPanel' => true,
'maxDate' => date('d M Y'),
'minDate' => date('d M Y',strtotime('-10 days')),
'maxDateTo' => date('d M Y',strtotime('+30 days')),
'minDateTo' => date('d M Y',strtotime('-10 days')),
]
]);