PHP code example of nattreid / calendar

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

    

nattreid / calendar example snippets


protected function createComponentCalendar(): \Nattreid\Calendar\Calendar
{
    $calendar = new \Nattreid\Calendar\Calendar();
    $calendar
        ->showOtherDays()
        ->showMonth()
        ->showYear()
        ->setFirstDayOfWeek(1)
        ->setNumberOfMonths(3)
        ->setFormat('Y-m-d')
        ->disableBeforeCurrent()
        ->setSelected(new DateTime, (new DateTime)->modify('+ 1 day'))
        ->setDisabledDays([
            (new DateTime)->modify('+ 1 day'),
            (new DateTime)->modify('+ 7 day'),
            (new DateTime)->modify('+ 8 day'),
            (new DateTime)->modify('+ 14 day'),
        ])
        ->setDayRenderer(function (Day $day) {
            return 'Day is ' . $day->day;
        })
        ->setDayTemplate(__DIR__ . '/templates/day.latte', ['foo' => 5])
        ->getTranslator()->setLang('en');

    return $calendar;
}