Bỏ qua để đến nội dung
PHP Ecosystem
Explore

TimePicker

Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.

Bootstrap time picker for Yii2 forms

Standalone and model-bound inputs, configurable display formats, and canonical form submission

Select a time with the mouse or keyboard arrow keys. This extension grew out of Kartik Visweswaran’s Krajee widget, which wrapped rendom’s TimePicker plugin, forked from jdewit’s TimePicker.

Studio booking form with the start time picker open, a 24-hour end time field, and both submitted values in HH:mm

TimePicker features: Yii2 forms, Bootstrap 3/4/5, time formats, layouts and bundled assets

Install with Composer:

Terminal window
composer require yii2-extensions/time-picker:^2.0

Load the Bootstrap CSS that matches your application’s bsVersion. On Yii 2.0.55, you can use an installed Yii Bootstrap asset adapter; on Yii 22, provide the Bootstrap CSS and npm jQuery assets in the application. See the installation guide and upgrade notes.

Render a standalone input:

use yii\helpers\Html;
use yii2\extensions\timepicker\TimePicker;
echo Html::label('Start time', 'start-time');
echo TimePicker::widget(
[
'name' => 'start_time',
'value' => '11:24 AM',
'options' => ['id' => 'start-time'],
'pluginOptions' => [
'showSeconds' => true,
],
],
);

Or bind the widget to a model attribute inside an existing ActiveForm:

use yii2\extensions\timepicker\TimePicker;
echo $form
->field($model, 'start_time')
->widget(
TimePicker::class, [
'pluginOptions' => [
'showMeridian' => false,
'defaultTime' => false,
],
]
);

Practical guides and usage examples for time inputs, Bootstrap integration and canonical form submission.

The guides and the API reference generated from the PHPDoc in src/ are published at https://yii2-framework.github.io/docs/extensions/time-picker/.

AI agents: read the documentation index and fetch the Markdown version of a page by appending index.md to its URL. The AI agents guide covers skill installation, client setup and verification.

  • 🤖 yii2-time-picker skill: configure Bootstrap markup, icons, and plugin options; verify submitted time values and form behavior.

See the repository guides, the skill source, the source PHPDoc, and the changelog. Check the guides against the installed revision before applying examples.

Originally developed by Kartik Visweswaran as Krajee TimePicker. Stefano Mtangoo adapted the extension for Yii2 Extensions. The upstream copyright and BSD-3-Clause terms remain in LICENSE.md.

Follow on X Follow on Facebook Join our Subreddit Join on Telegram

License

The bundled Bootstrap Timepicker JavaScript and CSS also carry Joris de Wit’s MIT notice.