kartik-v/yii2-date-range
Composer 安装命令:
composer require kartik-v/yii2-date-range
包简介
An advanced Yii 2 date range picker input for based on bootstrap-daterangepicker plugin.
README 文档
README
yii2-date-range
An advanced date range picker input for Yii Framework 2 based on dangrossman/bootstrap-daterangepicker plugin. The date range picker widget is styled for Bootstrap 3.x and 4.x versions and creates a dropdown menu from which a user can select a range of dates. If the plugin is invoked with no options, it will present two calendars to choose a start and end date from. Optionally, you can provide a list of date ranges the user can select from instead of choosing dates from the calendars. If attached to a text input, the selected dates will be inserted into the text box. Otherwise, you can provide a custom callback function to receive the selection.
Additional enhancements added for this widget (by Krajee):
- allows ability to work with Bootstrap input group addons and set the picker position to point at the input-group-addon icon.
- enhanced translation features using yii i18n message files.
- automatically convert format from PHP Date/time format to Moment.js Date/time format.
- automatically trigger change of base field to enforce Yii ActiveField validation
- ability to set the widget to display a preset dropdown of date options within a container (and hidden input).
- style the container options as per your need using templates
- automatically disable date-range based on disabled/readonly options.
Demo
You can see detailed documentation on usage of the extension.
Release Changes
Refer the CHANGE LOG for details of various releases.
Installation
The preferred way to install this extension is through composer.
Note: Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the
minimum-stabilitysettings for your application's composer.json.
Either run
$ php composer.phar require kartik-v/yii2-date-range "dev-master"
or add
"kartik-v/yii2-date-range": "dev-master"
to the require section of your composer.json file.
Usage
DateRangePicker
use kartik\daterange\DateRangePicker; echo DateRangePicker::widget([ 'model'=>$model, 'attribute'=>'datetime_range', 'convertFormat'=>true, 'pluginOptions'=>[ 'timePicker'=>true, 'timePickerIncrement'=>30, 'locale'=>[ 'format'=>'Y-m-d h:i A' ] ] ]);
or using seperate min/max attributes on model
use kartik\daterange\DateRangePicker; echo DateRangePicker::widget([ 'model'=>$model, 'attribute'=>'datetime_range', 'convertFormat'=>true, 'startAttribute'=>'datetime_min', 'endAttribute'=>'datetime_max', 'pluginOptions'=>[ 'timePicker'=>true, 'timePickerIncrement'=>30, 'locale'=>[ 'format'=>'Y-m-d h:i A' ] ] ]);
DateRangeBehavior
use kartik\daterange\DateRangeBehavior; class UserSearch extends User { public $createTimeRange; public $createTimeStart; public $createTimeEnd; public function behaviors() { return [ [ 'class' => DateRangeBehavior::className(), 'attribute' => 'createTimeRange', 'dateStartAttribute' => 'createTimeStart', 'dateEndAttribute' => 'createTimeEnd', ] ]; } public function rules() { return [ // ... [['createTimeRange'], 'match', 'pattern' => '/^.+\s\-\s.+$/'], ]; } public function search($params) { $query = User::find(); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['>=', 'createdAt', $this->createTimeStart]) ->andFilterWhere(['<', 'createdAt', $this->createTimeEnd]); return $dataProvider; } }
License
yii2-date-range is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.
kartik-v/yii2-date-range 适用场景与选型建议
kartik-v/yii2-date-range 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 4.55M 次下载、GitHub Stars 达 89, 最近一次更新时间为 2014 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bootstrap」 「time」 「date」 「extension」 「widget」 「range」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kartik-v/yii2-date-range 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kartik-v/yii2-date-range 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kartik-v/yii2-date-range 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Tools to convert between .NET and PHP date formats
Adds the EDTF data type to Wikibase
A powerful event calendar Tool for Laravel's Nova 5.
Date component is a set of methods to help with the manipulation of dates.
Bureaux A Partager Edit - Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Delayed Process For Laravel.
统计信息
- 总下载量: 4.55M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 92
- 点击次数: 28
- 依赖项目数: 74
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-07-09