maddoger/yii2-datetimepicker Yii2 DateTimePicker Widget.

extensionwidget

Yii2 DateTimePicker and date format behavior

DateTimePicker widget is a wrapper of Bootstrap DatePicker for Yii 2 framework.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist maddoger/yii2-datetimepicker "*"

or add

"maddoger/yii2-datetimepicker": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by:

use maddoger\widgets\DateTimePicker;

echo $form->field($model, 'field')->widget(DateTimePicker::className());

Date Attribute

For datetime format and timezone conversation you can use DateTimeBehavior.

In model behaviors for timestamp field:

[
    'class' => DateTimeBehavior::className(),
    'attributes' => ['published_at'],
    'originalFormat' => 'U', //original format
    'originalTimeZone' => 'UTC', //original timezone

    'timeZone' => 'Europe/London', //local timezone
    'format' => 'datetime', //local format, Formatter format
]

Now you can use published_at as original attribute and published_at_local as user read-write attribute.

For date fields:

[
    'class' => DateTimeBehavior::className(),
    'attributes' => ['birth_date'],
    'originalFormat' => 'Y-m-d',
    'format' => 'date',
    'timeZone' => 'UTC',
]

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



v2.0.0 is the latest of 13 releases



MIT license
Stats
1 github stars & 0 github forks
0 downloads in the last day
2 downloads in the last 30 days
294 total downloads