PHP code example of janisto / yii2-timepicker

1. Go to this page and download the library: Download janisto/yii2-timepicker 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/ */

    

janisto / yii2-timepicker example snippets


php composer.phar 

echo TimePicker::widget([
     //'language' => 'fi',
    'model' => $model,
    'attribute' => 'created_at',
    'mode' => 'datetime',
    'clientOptions' => [
        'dateFormat' => 'yy-mm-dd',
        'timeFormat' => 'HH:mm:ss',
        'showSecond' => true,
    ]
]);

echo TimePicker::widget([
    //'language' => 'fi',
    'model' => $model,
    'attribute' => 'created_at',
    'mode' => 'datetime',
    'inline' => true,
    'clientOptions' => [
        'onClose' => new \yii\web\JsExpression('function(dateText, inst) { console.log("onClose: " + dateText); }'),
        'onSelect' => new \yii\web\JsExpression('function(dateText, inst) { console.log("onSelect: " + dateText); }'),
    ]
]);

echo TimePicker::widget([
     //'language' => 'fi',
    'name'  => 'from_time',
    'value'  => $value,
    'mode' => 'time',
    'clientOptions' => [
        'hour' => date('H'),
        'minute' => date('i'),
        'second' => date('s'),
    ]
]);

echo $form->field($model, 'field')->widget(\janisto\timepicker\TimePicker::className(), [
    //'language' => 'fi',
    'mode' => 'datetime',
    'clientOptions' => [
        'dateFormat' => 'yy-mm-dd',
        'timeFormat' => 'HH:mm:ss',
        'showSecond' => true,
    ]
]);