1. Go to this page and download the library: Download lisoing/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/ */
lisoing / calendar example snippets
// Just extend AbstractLunisolarCalendar and implement a few methods
final class NepalCalendar extends AbstractLunisolarCalendar
{
// Implement 8 simple methods - that's it!
// The abstract class handles all the complex date conversion logic
}
use Lisoing\Holidays\Holidays;
use Lisoing\Countries\Cambodia;
// Using country helper with holiday() method
$holidays = Holidays::for(Cambodia::holiday(), year: 2025, locale: 'en')->get();
// Using country helper instance
$holidays = Holidays::for(Cambodia::make(), year: 2025, locale: 'en')->get();
// Or by country code string
$holidays = Holidays::for('KH', year: 2025, locale: 'en')->get();
use Carbon\CarbonImmutable;
use Lisoing\Calendar;
use Lisoing\Countries\Cambodia;
$gregorian = CarbonImmutable::parse('2025-04-14', 'Asia/Phnom_Penh');
// Convert to lunisolar calendar
$lunisolarDate = Calendar::for(Cambodia::class)
->fromCarbon($gregorian)
->toLunisolar();
echo $lunisolarDate->getCalendar(); // km
// Convert to Islamic (lunar) calendar
$islamicDate = Calendar::for('gregorian')
->fromCarbon($gregorian)
->toIslamic();
echo $islamicDate->getCalendar(); // islamic
// Convert back to Gregorian (solar)
$backToGregorian = $lunisolarDate->toGregorian();
echo $backToGregorian->getCalendar(); // gregorian
// Chain calendar conversions
$result = Calendar::for('gregorian')
->fromCarbon($gregorian)
->toLunisolar('km') // Switch to Khmer lunisolar
->toGregorian() // Switch back to Gregorian
->toIslamic() // Switch to Islamic lunar
->toString(); // Format as string
use Lisoing\Calendar\Holidays\HolidayManager;
use Lisoing\Calendar\Support\CalendarToolkit;
// Method 1: Using HolidayManager
$manager = app(HolidayManager::class);
$holidays = $manager->forCountry(2025, 'KH', 'en');
foreach ($holidays as $holiday) {
echo $holiday->name(); // Holiday name
echo $holiday->date()->format('Y-m-d'); // Date
}
// Method 2: Using CalendarToolkit
$toolkit = CalendarToolkit::make();
$newYear = $toolkit->holiday('khmer_new_year', 2025, 'KH', 'en');
echo $newYear?->name(); // Khmer New Year
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.