PHPackages                             avenirer/php-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. avenirer/php-calendar

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

avenirer/php-calendar
=====================

A PHP class to generate calendars.

00PHP

Since Nov 6Pushed 3y ago1 watchersCompare

[ Source](https://github.com/avenirer/php-calendar)[ Packagist](https://packagist.org/packages/avenirer/php-calendar)[ RSS](/packages/avenirer-php-calendar/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

php-calendar
============

[](#php-calendar)

Usage example
-------------

[](#usage-example)

Initiate class:

```
$calendar = new Calendar;
```

Then simply chain the settings:

```
$returned = $calendar
  ->setLocale('ro')
  ->addEvents($events)
  ->weekStartsMonday()
  ->padWithZeros()
  ->showMonthName()
  ->addDayCustomLink('/test/{year}/{month}/{day}')
  ->getMonth('2022-11-01')
  ->asMatrix();
```

The bare minimum to setup the calendar is:

```
$returned = $calendar->getMonth('2022-11-01')->asMatrix();
```

If you want to have further settings, you can use the chaining of methods before using the `getMonth()` method.

Let's explain...
----------------

[](#lets-explain)

### Set the language

[](#set-the-language)

We can set the language of the using the `setLocale()` method. If we want to use English, we can forget about this method. Otherwise, you can choose from 'fr' (French) and 'ro' (Romanian).

### Add events to calendar

[](#add-events-to-calendar)

You can add events to the calendar if you consider it useful. In order to add events, you should create an Events object:

```
$events = new Events;

$events->add(
  [
    'startDate' => '2022-11-22',
    'startTime' => '13:10',
    'title' => 'Event title',
  ],
);
```

By using the add() method to which you pass an array with the event details, you can add the event details. The required fields for the event are the `startDate` and the `title`. The array can also receive other parameters, if you think you need them:

```
[
  'startDate' => '2022-11-22', // start date of the event
  'startTime' => '13:10', // start time of the event
  'endDate' => '2022-12-01', // end date of the event
  'endTime' => '14:00', // end time of the event
  'title' => 'Event title', // the event title
  'shortContent' => 'The teaser of the content', // a short description of the event
  'content' => 'Full description of the event', // a longer description of the event
  'link' => 'https://link.to/wherever' // link to the event page
]
```

By the way, you can add multiple events on the same method:

```
$events->add(
  [
    [
      'startDate' => '2022-11-22',
      'startTime' => '13:10',
      'title' => 'Event title',
    ],
    [
      'startDate' => '2022-12-22',
      'startTime' => '13:40',
      'title' => 'One Event title',
    ],
  ]
);
```

### Does the week start on Monday?

[](#does-the-week-start-on-monday)

If you want to set the week to start on Monday, as in "not the American style", you can use the method `weekStartsMonday()`.

### Set a link to be used when someone clicks on the day

[](#set-a-link-to-be-used-when-someone-clicks-on-the-day)

If you want to further use the calendar and make it interactive by allowing users to click on the days and be taken to specific url, you can use the `addDayCustomLink()` using the `{year}`, `{month}` and `{day}` as placeholder for the values.

### What month are we talking about

[](#what-month-are-we-talking-about)

In order to retrieve the month, we use the `getMonth()` method, mentioning the year and month using a `Y-m-d` format. Don't worry about the day; the whole month will be created.

### What do we want to be returned

[](#what-do-we-want-to-be-returned)

#### Matrix

[](#matrix)

If you want to see the month as a matrix (HTML table), you can pass this as a second parameter of `getMonth()` method `...->getMonth('2022-11-01', 'matrix')`. Also, you can use another method after the `getMonth()`, `asMatrix()`.

#### List

[](#list)

If you want to see the month as a list (HTML UL list), you can pass this as a second parameter of `getMonth()` method `...->getMonth('2022-11-01', 'list')`. Also, you can use another method after the `getMonth()`, `asList()`.

#### Show the month name?

[](#show-the-month-name)

For the methods that output in HTML the month we can request that the month name be shown using the `showMonthName()` method.

#### Show leading zeros?

[](#show-leading-zeros)

For the one number month days (1 to 9) you can decide to prepend the day number with a leading zero. You can do this by adding the method `padWithZeros()`.

#### Array

[](#array)

If you just want an array with the month, you can pass this as a second parameter of `getMonth()` method `...->getMonth('2022-11-01', 'array')`. Also, you can use another method after the `getMonth()`, `asArray()`.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/19de436453bd36e6fd5062ee0918955e444a77ec374453c64e78e1359532a053?d=identicon)[avenirer](/maintainers/avenirer)

---

Top Contributors

[![avenirer](https://avatars.githubusercontent.com/u/3034772?v=4)](https://github.com/avenirer "avenirer (6 commits)")

### Embed Badge

![Health badge](/badges/avenirer-php-calendar/health.svg)

```
[![Health](https://phpackages.com/badges/avenirer-php-calendar/health.svg)](https://phpackages.com/packages/avenirer-php-calendar)
```

###  Alternatives

[alkoumi/laravel-hijri-date

Laravel package to Convert laravel date to our Amazing 💝 Hjri date {ummul qura and vice versa} . to look like \[ الخميس ، ٢٢ ربيع الآخر ، ١٤٤١ - ٠٧:٤٩ مساءً\]

109166.2k2](/packages/alkoumi-laravel-hijri-date)[uspdev/replicado

Classes PHP que consome dados do Replicado USP

136.2k7](/packages/uspdev-replicado)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
