janisto/yii2-timepicker Yii 2 widget for jQuery Timepicker Addon.

extensionwidgetdatetimedatetimetimepicker

Yii 2 Timepicker

Yii 2 widget for jQuery Timepicker Addon.

Software License Build Status Quality Score Packagist Version Total Downloads

Installation

If you do not have Composer, you may install it by following the instructions at getcomposer.org.

You can then install this package using the following command:

php composer.phar require "janisto/yii2-timepicker" "*"

or add

"janisto/yii2-timepicker": "*"

to the require section of your application's composer.json file.

Usage

See jQuery Timepicker options.

For example to use the timepicker with a yii\base\Model:

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); }'),
    ]
]);

The following example will use the name property instead:

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

You can also use this widget in an yii\widgets\ActiveForm using the yii\widgets\ActiveField::widget() method, for example like this:

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,
    ]
]);

Contributing

Please see CONTRIBUTING for details.

Credits

License

Public domain. Please see License File for more information.

Changelog

Changelog

All Notable changes to yii2-timepicker will be documented in this file.

1.1.0 - 2015-11-12

Fixed

  • Added fallback for timepicker language files
  • When using translations, asset was registered without timestamp when asset manager $appendTimestamp was enabled
  • Default time removed
  • Travis + Scrutinizer

1.0.0 - 2015-06-26

Fixed

  • Updated dependencies
  • Travis

0.1.0 - 2015-03-26

  • Initial release

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.1.0 is the latest of 3 releases



public domain license
Stats
9 github stars & 5 github forks
31 downloads in the last day
772 downloads in the last 30 days
76602 total downloads