PHPackages                             zdenekgebauer/month-calendar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zdenekgebauer/month-calendar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zdenekgebauer/month-calendar
============================

Simple HTML monthly calendar generator

v2.0.0(5y ago)12151wtfplPHPPHP &gt;=8.0

Since Dec 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/zdenekgebauer/monthcalendar)[ Packagist](https://packagist.org/packages/zdenekgebauer/month-calendar)[ RSS](/packages/zdenekgebauer-month-calendar/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (4)Used By (0)

MonthCalendar
=============

[](#monthcalendar)

Base class for rendering calendar from PHP scripts.

[![](https://github.com/zdenekgebauer/monthcalendar/workflows/build/badge.svg)](https://github.com/zdenekgebauer/monthcalendar/workflows/build/badge.svg)

Installation
------------

[](#installation)

`composer require zdenekgebauer/month-calendar`

Usage
-----

[](#usage)

```
$date = new DateTime();
$calendar = new Calendar($date);
$calendar->firstDayOfWeek(0); // 0-6, 0=Sunday
$calendar->showOtherMonths = true; // show days from previous and next month
echo $calendar->render();
```

### Customization

[](#customization)

```
class CustomCalendar extends ZdenekGebauer\MonthCalendar\Calendar
{
    /**
     * @return array
     */
    protected function weekdays(): array
    {
        // own weekdays names from Sunday
        return ['Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So'];
    }

    protected function renderCaption(): string
    {
        // own table caption
        return '' . $this->date->format('m/Y') . '';
    }

    protected function renderDay(DateTimeInterface $currentDate, bool $isOtherMonth = false): string
    {
        // own content of day, ie. info "occupied"
        $day = (int)$currentDate->format('j');
        $cssClass = '';
        $content =  '';
        if ($day === 10 || $day === 15) {
            $cssClass = 'occupied';
            $content =  'occupied';
        }
        if ($isOtherMonth) {
            $cssClass .= ' other-month';
        }

        return '
