Here we will share some useful carbon extensions, which we need in our daily work.
You can install the package via composer:
composer require laracraft-tech/carbon-extensions
The CarbonFiscalYear
class helps you to work with fiscal years!
It easily lets you know the fiscal years start and end of a given date.
Note: There is also a CarbonFiscalYearImmutable
, class which has the same API,
but it works immutable. For more information on immutables, check out the carbon docs.
// set your fiscal year start month and day
CarbonFiscalYear::setFiscalYearStart(4, 1);
$date = CarbonFiscalYear::parse("2022-03-30");
$date->startOfYear()->format("Y-m-d"); // 2021-04-01
$date->endOfYear()->format("Y-m-d"); // 2022-03-31
$date2 = CarbonFiscalYear::parse("2022-04-02");
$date2->startOfYear()->format("Y-m-d"); // 2022-04-01
$date2->endOfYear()->format("Y-m-d"); // 2023-03-31
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.