An immutable opening-hours engine built around typed schedules, date-specific override rules, and schema.org adapters.
Requires PHP 8.5+
composer require cline/opening-hoursuse Cline\OpeningHours\OpeningHours;
use Cline\OpeningHours\QueryOptions;
$openingHours = OpeningHours::fromArray([
'monday' => ['09:00-17:00'],
'tuesday' => ['09:00-17:00'],
'exceptions' => [
'2026-12-24' => [],
'2026-12-31 to 2027-01-02' => ['10:00-14:00'],
'01-01' => [],
],
], new QueryOptions(
timezone: 'Europe/Helsinki',
));
$openingHours->isOpenAt(new DateTimeImmutable('2026-03-09 10:00:00'));
$openingHours->nextOpen(new DateTimeImmutable('2026-03-09 18:00:00'));
$openingHours->asStructuredData();OpeningHours::fromArray()builds schedules from weekday definitions plus explicit exception rules.OpeningHours::fromWeeklySchedule()builds directly from typed value objects.OpeningHours::createFromStructuredData()imports schema.org opening hour specifications.QueryOptionscontrols input timezone, output timezone, and search limits for transition queries.
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.
The MIT License. Please see License File for more information.