code16/carbon-business-days
最新稳定版本:v1.1.0
Composer 安装命令:
composer require code16/carbon-business-days
包简介
A simple class for business days counting
README 文档
README
This package aims to count business working days between two Carbon dates.
Usage
$date = new BusinessDays(); // Set holidays (2018-1-1 is a Monday) $date->addHoliday(Carbon::createFromDate(2018, 1, 1)); // Should return 9 $days = $date->daysBetween( Carbon::createFromDate(2018, 1, 1), Carbon::createFromDate(2018, 1, 15) ); // Set a closed period (whole 2nd week) $date->addClosedPeriod( Carbon::createFromDate(2018, 1, 8), Carbon::createFromDate(2018, 1, 12) ); // Should return 5 $days = $date->daysBetween( Carbon::createFromDate(2018, 1, 1), Carbon::createFromDate(2018, 1, 15) );
Default for weekend days are saturdays and sundays, but it can be configured:
$date->setWeekendDays([Carbon::SUNDAY, Carbon::MONDAY]);
You can also add or subtract days from a given date:
$newDate = $date->addDaysTo( Carbon::createFromDate(2018, 5, 14), 10 ); $newDate = $date->subDaysFrom( Carbon::createFromDate(2018, 5, 14), 10 );
Installation
composer require code16/carbon-business-days
License
MIT
统计信息
- 总下载量: 327.97k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 54
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 未知