PHP code example of tiennk1995dev / japanese-holidays_php
1. Go to this page and download the library: Download tiennk1995dev/japanese-holidays_php 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/ */
tiennk1995dev / japanese-holidays_php example snippets
use JapaneseHolidays\HolidayCalculator;
use Carbon\Carbon;
$calculator = new HolidayCalculator();
$holidays = $calculator->getHolidays(2025);
foreach ($holidays as $holiday) {
echo $holiday['date']->format('Y-m-d') . ' - ' . $holiday['name'] . ' (' . $holiday['nameEn'] . ')' . PHP_EOL;
}
if ($calculator->isHoliday(Carbon::create(2025))) {
echo 'January 1, 2025 is a holiday.';
}
$name = $calculator->getHolidayName(Carbon::create(2025), 'en');
echo 'The holiday on January 1, 2025 is: ' . $name;
$start = Carbon::create(2025);
$end = Carbon::create(2025, 3, 31);
$holidaysBetween = $calculator->getHolidaysBetween($start, $end);
echo 'There are ' . $holidaysBetween->count() . ' holidays between ' . $start->format('Y-m-d') . ' and ' . $end->format('Y-m-d') . '.';
$workDays = $calculator->countWorkDays($start, $end);
echo 'There are ' . $workDays . ' work days between ' . $start->format('Y-m-d') . ' and ' . $end->format('Y-m-d') . '.';
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.