PHP code example of zaki / laravel-working-calendar

1. Go to this page and download the library: Download zaki/laravel-working-calendar 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/ */

    

zaki / laravel-working-calendar example snippets


use Zaki\WorkingCalendar\Facades\WorkingCalendar;

$status = WorkingCalendar::today(
    countryCode: 'TR',
    timezone: 'Europe/Istanbul',
);

$status->isWorkingDay;
$status->isHoliday;
$status->isWeekend;
$status->previousWorkingDay->toDateString();
$status->nextWorkingDay->toDateString();
$status->holidays;

$status = WorkingCalendar::inspect(
    date: '2026-04-23',
    countryCode: 'TR',
    timezone: 'Europe/Istanbul',
);

return $status->toArray();

WorkingCalendar::isHoliday('2026-04-23', 'TR');
WorkingCalendar::isWeekend('2026-07-24', 'SA');
WorkingCalendar::isWorkingDay('2026-04-24', 'TR');

$before = WorkingCalendar::previousWorkingDay('2026-04-23', 'TR');
$after = WorkingCalendar::nextWorkingDay('2026-04-23', 'TR');

$nearest = WorkingCalendar::nearestWorkingDays('2026-04-23', 'TR');

$settlementDate = WorkingCalendar::addWorkingDays(
    date: '2026-04-23',
    days: 3,
    countryCode: 'TR',
);

[
    'before' => CarbonImmutable::parse('2026-04-22'),
    'after' => CarbonImmutable::parse('2026-04-24'),
]

$status = WorkingCalendar::inspect(
    date: '2026-10-03',
    countryCode: 'DE',
    subdivision: 'DE-BY',
);

'weekends' => [
    'TR' => [6, 7],
    'SA' => [5, 6],
    'IN' => [7],
],

'forced_working_days' => [
    'TR' => ['2026-10-31'],
],

'forced_non_working_days' => [
    'TR' => ['2026-12-31'],
],

'custom_holidays' => [
    'TR' => [
        [
            'date' => '2026-12-31',
            'name' => 'Company Closure',
            'local_name' => 'Şirket Tatili',
            'global' => true,
            'types' => ['Company'],
        ],
    ],
],

[
    'date' => '2026-08-01',
    'name' => 'Regional Closure',
    'global' => false,
    'subdivisions' => ['DE-BY'],
]

use Zaki\WorkingCalendar\WorkingCalendar;

final class SettlementService
{
    public function __construct(
        private readonly WorkingCalendar $calendar,
    ) {
    }

    public function settlementDate(string $createdAt, string $country): string
    {
        return $this->calendar
            ->addWorkingDays($createdAt, 2, $country)
            ->toDateString();
    }
}

use Zaki\WorkingCalendar\Contracts\HolidayProvider;

final class OfficialGovernmentHolidayProvider implements HolidayProvider
{
    public function holidays(
        int $year,
        string $countryCode,
        ?string $subdivision = null,
    ): array {
        // Return a list of Holiday DTOs.
    }
}

'providers' => [
    OfficialGovernmentHolidayProvider::class,
    \Zaki\WorkingCalendar\Providers\NagerDateHolidayProvider::class,
    \Zaki\WorkingCalendar\Providers\YasumiHolidayProvider::class,
],
bash
php artisan vendor:publish --tag=working-calendar-config
bash
php artisan working-calendar:check TR \
    --date=2026-04-23 \
    --timezone=Europe/Istanbul
bash
php artisan working-calendar:check DE \
    --date=2026-10-03 \
    --subdivision=DE-BY