plumphp/plum-date
Composer 安装命令:
composer require plumphp/plum-date
包简介
PlumDate provides date and time converters for Plum.
README 文档
README
PlumDate provides date and time converters for Plum. Plum is a data processing pipeline for PHP.
Developed by Florian Eckerstorfer in Vienna, Europe.
Installation
You can install PlumDate using Composer.
$ composer require plumphp/plum-date
Usage
Please refer to the Plum documentation for more information.
Currently PlumDate contains converters to convert strings and timestamps into DateTime objects and to convert
DateTime objects into strings and timestamps and filters to detect whether a date is before or after a certain point
in time.
Overview
Converters
DateTimeToStringConverterDateTimeToTimestampConverterStringToDateTimeConverterTimestampToDateTimeConverter
Filters
DateTimeToStringConverter
Plum\PlumDate\DateTimeToStringConverter converts a DateTime object into a string. The format of the string has to
be passed to the constructor.
use Plum\PlumDate\DateTimeToStringConverter; $converter = new DateTimeToStringConverter('y-m-d H:i:s'); $converter->convert(new DateTime()); // -> e.g., "2015-10-21 19:28:00"
DateTimeToTimestampConverter
Plum\PlumDate\DateTimeToTimestampConverter converts a DateTime object into a timestamp.
use Plum\PlumDate\DateTimeToTimestampConverter; $converter = new DateTimeToTimestampConverter(); $converter->convert(new DateTime()); // -> e.g., 1445448480
StringToDateTimeConverter
Plum\PlumDate\StringToDateTimeConverter takes a string and returns a DateTime object. The constructor takes an
optional DateTimeZone object that is passed to the DateTime constructor.
use Plum\PlumDate\StringToDateTimeConverter; $converter = new StringToDateTimeConverter(); $converter->convert('2015-10-21 19:28:00'); // -> DateTime $converter = new StringToDateTimeConverter(new DateTimeZone('Europe/Vienna')); $converter->convert('2015-10-21 19:28:00'); // -> DateTime
TimestampToDateTimeConverter
Plum\PlumDate\TimestampToDateTimeConverter takes a timestamp and returns a DateTime object. An instance of
DateTimeZone can be passed to the constructor, which will be used to instantiate the DateTime object.
use Plum\PlumDate\TimestampToDateTimeConverter; $converter = new TimestampToDateTimeConverter(); $converter->convert(1445448480); // -> DateTime $converter = new TimestampToDateTimeConverter(new DateTimeZone('Europe/Vienna')); $converter->convert(1445448480); // -> DateTime
AfterFilter
Plum\PlumDate\AfterFilter returns true for all dates that are after a given date.
use Plum\PlumDate\AfterFilter; $filter = new AfterFilter(new DateTime('2015-10-21 19:28')); $filter->filter(new DateTime('2015-10-26 21:00')); // -> true $filter->filter(new DateTime('1955-11-12 18:38')); // -> false // Same date as in constructor: $filter->filter(new DateTime('2015-10-21 19:28')); // -> false
BeforeFilter
Plum\PlumDate\BeforeFilter returns true for all dates that are before a given date.
use Plum\PlumDate\BeforeFilter; $filter = new BeforeFilter(new DateTime('2015-10-21 19:28')); $filter->filter(new DateTime('1955-11-12 18:38')); // -> true $filter->filter(new DateTime('2015-10-26 21:00')); // -> false // Same date as in constructor: $filter->filter(new DateTime('2015-10-21 19:28')); // -> false
RangeFilter
Plum\PlumDate\RangeFilter returns true for all dates that lie within a given range of dates.
use Plum\PlumDate\AfterFilter; $filter = new AfterFilter(new DateTime('2000-01-01 00:00:00'), new Date('2009-12-31 23:59:59')); $filter->filter(new DateTime('2005-07-07 12:00:00')); // -> true $filter->filter(new DateTime('2015-10-21 19:28:00')); // -> false // Same date as in start or end date: $filter->filter(new DateTime('2000-01-01 00:00:00')); // -> true $filter->filter(new DateTime('2009-12-31 23:59:59')); // -> true
Change Log
Version 0.1 (23 October 2015)
- Initial release
License
The MIT license applies to plumphp/plum-date. For the full copyright and license information, please view the LICENSE file distributed with this source code.
plumphp/plum-date 适用场景与选型建议
plumphp/plum-date 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 plumphp/plum-date 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 plumphp/plum-date 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-23