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.
统计信息
- 总下载量: 22.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-18