danharper/dti
Composer 安装命令:
composer require danharper/dti
包简介
Parse ISO 8601 date, duration and interval strings into DateTime objects
README 文档
README
Parse ISO 8601 dates and intervals.
Installation
Install via Composer by adding the following line to the dependencies in your composer.json:
danharper/dti: "~1.0"
And run composer install/composer update
Usage
$dti = new danharper\DTI;
Passing a single ISO 8601 datetime string will provide you with an array containing that time, and the current time.
list($from, $to) = $dti->parse('2007-03-01T13:00:00Z');
Passing a single ISO 8601 duration string will substract that duration from the current time.
list($from, $to) = $dti->parse('PT2H30M'); // from is set to 2h30m before the current time
Optionally, provide parse() with the default time to use instead of the current time:
$dti->parse('PT2H30M', new DateTime('2001-01-01'));
Passing a ISO 8601 duration string consisting of two datetimes, will give you them:
$dti->parse('2007-03-01T13:00:00Z/2008-05-11T15:30:00Z');
A duration string consisting of a datetime and a duration will give the datetime provided, and the datetime with the duration added to it.
$dti->parse('2007-03-01T13:00:00Z/P1Y2M10DT2H30M');
And in reverse, will give you the datetime with the duration substracted, and the datetime:
$dti->parse('PT2H30M/2007-03-01T13:00:00Z');
danharper/dti 适用场景与选型建议
danharper/dti 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45.23k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2013 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 danharper/dti 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 danharper/dti 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 45.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 24
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-03-14