cherrypick/hammertime
最新稳定版本:v0.4.1
Composer 安装命令:
composer require cherrypick/hammertime
包简介
Some extensions to Carbon (a DateTime class)
README 文档
README
This date library extends Carbon with some more sophisticated date calculations and getters / setters for all date parts.
Installation
Install using composer:
composer require cherrypick/hammertime
Features
More sophisticated date calculations
The date calculations with HammerTime are closer to real world problems. When you are at the end of a month and add another month, it doesn't leap into the beginning of the month afterwards.
$date = HammerTime::createFromDate(2014, 5, 31); $date->addMonths(1); // 2014-06-30 (with default PHP DateTime (and Carbon) it would be 2014-07-01) $date = HammerTime::createFromDate(2012, 2, 29); $date->addYear(1); // 2013-02-28 (with default PHP DateTime (and Carbon) it would be 2013-03-01)
Similar, it applies to the diff of months. You can find more information and examples here.
$date1 = HammerTime::createFromDate(2014, 2, 1); $date2 = HammerTime::createFromDate(2014, 3, 1); $date1->diffInMonths($date2); // 1 (with default PHP DateTime (and Carbon) it would be 0)
Date Comparisons
This library provides some more clear names for date comparisons.
$date1->isSameDate($date2); $date1->isBefore($date2); $date1->isBeforeOrEqual($date2); $date1->isAfter($date2); $date1->isAfterOrEqual($date2);
Getters and Setters
This library provides getters and setters for all available date information:
$date = HammerTime::createFromDate(2014, 11, 30, 12, 42, 42); $date->getDay(); // 30 $date->getMonth(); // 11 $date->getYear(); // 2014 $date->getHour(); // 12 $date->getMinute(); // 42 $date->getSecond(); // 42 // and many more... // the same applies to setters. $date->setDay(20); // 2014-11-20 // etc..
There are Getters and Setters for every availble property.
cherrypick/hammertime 适用场景与选型建议
cherrypick/hammertime 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.54k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2014 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cherrypick/hammertime 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cherrypick/hammertime 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 22.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-18