PHP code example of cline / opening-hours
1. Go to this page and download the library: Download cline/opening-hours library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cline / opening-hours example snippets
use 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();