minasm / carbon-uk
A basic wrapper for citco/carbon which returns business days between two given dates.
Requires
- php: ^8.3
- citco/carbon: ^3.0.0
Requires (Dev)
- laravel/pint: ^v1.18
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^11.4.0
README
Minasm/Carbon is a package that extends the functionality of the citco/carbon package, which provides a wrapper for the Carbon date/time library with support for UK bank holidays.
Installation
To install Minasm/Carbon, simply require it using Composer:
composer require minasm/carbon-uk
Usage
Minasm/Carbon provides a single method: getBusinessDays()
. This method calculates the number of business days between two dates, excluding weekends and UK bank holidays. Here's how you can use it:
use Minasm\Carbon;
$startDate = '01/03/2023';
$endDate = '31/03/2023';
$businessDays = (new Carbon())->getBusinessDays($startDate, $endDate);
echo "There are {$businessDays} business days between {$startDate} and {$endDate}";
The output of the above code will be:
There are 23 business days between 01/03/2023 and 31/03/2023.
The getBusinessDays()
method takes three parameters:
$start
(string): the start date, in the format specified by the$format
parameter (default is'd/m/Y'
).$end
(string): the end date, in the format specified by the$format
parameter (default is'd/m/Y'
).$format
(string, optional): the format of the$start
and$end
parameters (default is'd/m/Y'
).
Issues
If you encounter any bugs or have any feature requests, please submit them to the GitHub issue tracker.
License
Minasm/Carbon is open source software licensed under the MIT license.