A Carbon mixin for PHP that adds business day and opening hour calculations with holiday support.
Business Time is a PHP library that extends Carbon date/time objects with business logic for handling working days, opening hours, and holidays. It solves the problem of performing date calculations based on business schedules, such as checking if a business is open, calculating next open/close times, and adding business hours while skipping closed periods.
PHP developers building applications that require business schedule calculations, such as booking systems, service availability checkers, or workforce management tools.
Developers choose Business Time because it seamlessly integrates with Carbon, provides comprehensive business logic out of the box, and offers flexibility through configurable schedules, holiday support, and Laravel integration.
Carbon mixin to handle business days and opening hours
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Seamlessly extends Carbon objects with business logic methods like isOpen() and addOpenHours(), allowing developers to use familiar Carbon syntax.
Includes built-in holiday regions (e.g., us-ny) and allows custom holidays, with options to automatically treat them as closed days via 'holidaysAreClosed'.
Supports multiple time ranges per day, dynamic exceptions with callbacks, and overflow handling for ranges crossing midnight, as shown in the examples.
Provides a config/carbon.php file for Laravel integration, reducing setup boilerplate and enabling global business time settings.
Allows creating separate Schedule objects for different business locations or rules, facilitating complex multi-tenant applications.
Setting up opening hours, exceptions, and holidays requires a detailed array structure that can be error-prone and time-consuming for initial setup.
Relies on Carbon and spatie/opening-hours, increasing project dependencies and potential version compatibility issues.
The extensive API with methods like diffAsBusinessInterval and dynamic exception handlers can overwhelm developers, especially those new to business logic calculations.
While mentioned, timezone nuances require manual conversion efforts, and the library does not automatically adjust holidays or schedules for different timezones.