https://github.com/laracraft-tech/carbon-extensions
Some useful extension for the carbon library!
https://github.com/laracraft-tech/carbon-extensions
carbon date fiscalyearutils php
Last synced: 7 months ago
JSON representation
Some useful extension for the carbon library!
- Host: GitHub
- URL: https://github.com/laracraft-tech/carbon-extensions
- Owner: laracraft-tech
- License: mit
- Created: 2023-03-31T14:58:15.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-11-25T09:17:04.000Z (7 months ago)
- Last Synced: 2025-11-28T15:54:15.944Z (7 months ago)
- Topics: carbon, date, fiscalyearutils, php
- Language: PHP
- Homepage:
- Size: 43.9 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Carbon Extensions
[](https://packagist.org/packages/laracraft-tech/carbon-extensions)
[](https://github.com/laracraft-tech/carbon-extensions/actions/workflows/run-tests.yml)
[](https://github.com/laracraft-tech/carbon-extensions/actions/workflows/fix-php-code-style-issues.yml)
[](https://packagist.org/packages/laracraft-tech/carbon-extensions)
Here we will share some useful carbon extensions, which we need in our daily work.
## Installation
You can install the package via composer:
```bash
composer require laracraft-tech/carbon-extensions
```
## Usage
### CarbonFiscalYear
---
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](https://carbon.nesbot.com/docs/).
```php
// 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
```
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Zacharias Creutznacher](https://github.com/laracraft-tech)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.