PHP calendar handler class.

v1.0.2 2019-05-08 00:45 UTC

This package is auto-updated.

Last update: 2023-01-27 09:06:29 UTC


Latest Stable Version Total Downloads License

Calendar handler library for PHP.

NOTE: This class will not echo / print the calendar.


  • Handles monthly weeks and days.
  • Ability to attach data.
  • Able to be render in any custom template.


With composer, make the dependecy required in your project:

composer require 10quality/php-calendar


The following example will build the calendar for the current month:

use TenQuality\Utility\Calendar;

$calendar = new Calendar();

Attaching data

// Example
$data = array();
$data[] = $obj; // Either ARRAY or OBJECT

$calendar = new Calendar();
$calendar->data = $data;
// Array column or object filed containing the date related to each data row
$calendar->dataDateFiled = 'dateCreated';
// Build


Printing example:

            <?php foreach ($calendar->headers as $header) : ?>
                <th><?php echo $header ?></th>
            <?php endforeach ?>
        <?php foreach ($calendar->weeks as $week) : ?>
                <?php foreach ($week->days as $day) : ?>
                        <h2><?php echo $day->number ?></h2>
                        <?php foreach ($day->data as $row) : ?>
                            <!--TODO: What ever needs to be done with data-->
                        <?php endforeach ?>
                <?php endforeach ?>
        <?php endforeach ?>

Other properties or methods

Build calendar for a specific date:

$calendar = new Calendar('2017-01-25');

Get previous and next month dates:

$calendar = new Calendar('2017-01-25');

Coding guidelines



The MIT License (MIT)

Copyright (c) 2017 10Quality.