PHP code example of fastbolt / working-day-provider
1. Go to this page and download the library: Download fastbolt/working-day-provider 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/ */
fastbolt / working-day-provider example snippets
use Fastbolt\WorkingDayProvider\WorkingDayProvider;
$workingDayProvider = new WorkingDayProvider();
$workingDays = $workingDayProvider->getWorkingDaysForPeriod(
new DateTimeImmutable('2023-01-01'),
new DateTimeImmutable('2023-01-07')
);
// $workingDays will be 5
use Acme\Provider\HolidayProvider;
use Fastbolt\WorkingDayProvider\WorkingDayProvider;
$holidayProvider = new HolidayProvider());
# Example `$holidayProvider->getHolidaysForDateRange(2022-12-24, 2022-12-26)` returns one holiday for 26th of december.
$workingDayProvider = new WorkingDayProvider($holidayProvider);
$workingDays = $workingDayProvider->getWorkingDaysForPeriod(
new DateTimeImmutable('2022-12-24'),
new DateTimeImmutable('2022-12-26')
);
// $workingDays will be 0 (days are saturday, sunday and holiday)
use Fastbolt\WorkingDayProvider\Configuration;
use Fastbolt\WorkingDayProvider\WorkingDayProvider;
$configuration = new Configuration(['excludeWeekDays' => [1, 6, 7]);
$workingDayProvider = new WorkingDayProvider(null, $configuration);
$workingDays = $workingDayProvider->getWorkingDaysForPeriod(
new DateTimeImmutable('2022-12-24'),
new DateTimeImmutable('2022-12-26')
);
// $workingDays will be 0 (working days monday, saturday and sunday are all configured as non-working days)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.