Space Cat, Prince Among Thieves

SimpleCalendar

Recent Activity

GitHub (web-flow)

Merge pull request #48 from donatj/dependabot/composer/phpstan/phpstan-tw-2.3.4

Update phpstan/phpstan requirement from ^2.3.2 to ^2.3.4


Update phpstan/phpstan requirement from ^2.3.2 to ^2.3.4

Updates the requirements on phpstan/phpstan to permit the latest version.


updated-dependencies:

  • dependency-name: phpstan/phpstan
    dependency-version: 2.3.4
    dependency-type: direct:development
    ...

Merge pull request #47 from donatj/dependabot/composer/phpstan/phpstan-tw-2.3.2

Update phpstan/phpstan requirement from ^2.3.0 to ^2.3.2


Merge pull request #41 from donatj/ci/add-php-8-6

ci: test against PHP 8.6


Jesse Donat (donatj)

ci: allow PHP CS Fixer on PHP 8.6


ci: test against PHP 8.6


GitHub (web-flow)

Update phpstan/phpstan requirement from ^2.3.0 to ^2.3.2

Updates the requirements on phpstan/phpstan to permit the latest version.


updated-dependencies:

  • dependency-name: phpstan/phpstan
    dependency-version: 2.3.2
    dependency-type: direct:development
    ...

Merge pull request #46 from donatj/fixup/formatting-and-docs

Fixup/formatting and docs


Jesse Donat (donatj)

Update mddoc


versioning-strategy: increase


Wire up corpus/php-cs-fixer-config


GitHub (web-flow)

Merge pull request #45 from donatj/fix/improve-test-coverage

Improve calendar test coverage


Jesse Donat (donatj)

Improve calendar test coverage


GitHub (web-flow)

Merge pull request #44 from donatj/fix/upgrade-phpstan

Upgrade PHPStan to 2.3


Jesse Donat (donatj)

Shape weekday return


Shape weekday names


Type private calendar state


Describe calendar class overrides


Upgrade PHPStan to 2.3


GitHub (web-flow)

Check documentation in CI (#43)

  • Add documentation workflow

  • Check documentation in CI

  • Switch mddoc to composer autoloader


Merge pull request #42 from donatj/ci/add-coveralls

Add Coveralls workflow


Jesse Donat (donatj)

Add Coveralls workflow


GitHub (web-flow)

Bump actions/checkout from 6 to 7 (#39)

Bumps actions/checkout from 6 to 7.


updated-dependencies:

  • dependency-name: actions/checkout
    dependency-version: '7'
    dependency-type: direct:production
    update-type: version-update:semver-major
    ...

Merge pull request #37 from donatj/php-cs-fixer-dry-run

Run php-cs-fixer in dry-run mode in CI


Run php-cs-fixer in dry-run mode in CI


Update PHPUnit version constraint in composer.json


Jesse Donat (donatj)

Rebuild README


GitHub (web-flow)

Merge pull request #32 from donatj/donatj-patch-2

Add PHP version 8.5 to CI workflow


Add PHP version 8.5 to CI workflow


Bump actions/checkout from 5 to 6 (#31)

Bumps actions/checkout from 5 to 6.


updated-dependencies:

  • dependency-name: actions/checkout
    dependency-version: '6'
    dependency-type: direct:production
    update-type: version-update:semver-major
    ...

SimpleCalendar is a lightweight PHP library for generating HTML calendars. It provides a simple month-view calendar with support for events, date ranges, and customizable formatting.

It is designed to be easy to integrate into existing PHP projects without requiring a framework or JavaScript.

Much more information is available on GitHub.

Example Calendar

SunMonTueWedThuFriSat
Sample Event
Sample Event
     

Installation

Install SimpleCalendar using Composer:

composer require 'donatj/simplecalendar'

Sample Usage

<?php

require __DIR__ . '/vendor/autoload.php';

$calendar = new \donatj\SimpleCalendar();

$calendar->setStartOfWeek('Sunday');
$calendar->addDailyHtml('Sample Event', 'today', 'tomorrow');

echo $calendar->render();

This generates an HTML calendar for the current month with a sample event spanning today and tomorrow.

SimpleCalendar also supports displaying arbitrary months, changing weekday names, and customizing the generated HTML through CSS classes.

A sample stylesheet is available in the repository.

BuildDateNotes
v0.8.2
Download

What's Changed

Test in PHP 8.6

Full Changelog: https://github.com/donatj/SimpleCalendar/compare/v0.8.1...v0.8.2

v0.8.1
Download

What's Changed

Full Changelog: https://github.com/donatj/SimpleCalendar/compare/v0.8.0...v0.8.1

v0.8.0
Download

What's Changed

  • Major cleanup revision. Now ran through PHPStan level 9.
  • Minimum PHP bumped to 7.2

Full Changelog: https://github.com/donatj/SimpleCalendar/compare/v0.7.0...v0.8.0

v0.7.0
Download

This was originally intended to be a major release, but preventing interface changes was simple enough to keep this as a minor release.

Notable (Potentially Breaking) Changes

  • Increased Minimum PHP version to 5.5.0
  • Current date was separated from month due to issues it solved #7
  • Class names are now customizable #10
  • show() method now deprecated in favor of render()

Things to Watch Out For

  • Day names are no longer localized by default due to PHP 8.1 deprecating strftime ( thanks, @h1nds1ght )

What's Changed

New Contributors

Full Changelog: https://github.com/donatj/SimpleCalendar/compare/v0.6.2...v0.7.0

v0.6.2
Download

In fixing one issue with mismatched TRs I caused another. Special thanks to @keesiemeijer for the kind PR, the problem is now fixed complete with regression tests to prevent the problem from creeping up in the future.


Comment by: Joko Wandiro on

Joko Wandiro's Gravatar good PHP Class, very help me.
thanks a ton.

Comment by: joagido on

joagido's Gravatar what to do to start weeks on monday?

Comment by: Greg Duckworth on

Greg Duckworth's Gravatar This is a fantastic little script, although I don't suppose you could add the ability to move forward and back in months ?

Comment by: Jesse G. Donat on

Jesse G. Donat's Gravatar

The constructor on Simple Calendar takes a date string (see strtotime()) so an easy way is simply

$cal = new SimpleCalendar('+1 Month');

or

$cal = new SimpleCalendar('June 2012');

There is also a setDate method which allows you to change the date of the calendar after initial construction.


Comment by: Greg Duckworth on

Greg Duckworth's Gravatar Thanks, have it all working now.

Kudos again on the script!

Comment by: HvToor on

HvToor's Gravatar It looks great but when I download v0.3.2 and upload it to my website it won't work. I already changed the paths of the files to the right folder.

Hope you can help with it,

Comment by: Jesse G. Donat on

Jesse G. Donat's Gravatar Starting with .3.0 it is namespaced and requires PHP 5.3+, I'm sorry I did not update the documentation until just now. The example in the source code better illustrates this.

Comment by: Dirk on

Dirk's Gravatar As somebody already asked: Is there a simple way to make weeks start on mondays?

Thx in advance

Comment by: Vincent on

Vincent's Gravatar How to change the first day of the week is detailed in the 'sample usage'...

Comment by: Dirk on

Dirk's Gravatar $calendar->setStartOfWeek('Sunday');

works perfectly.

Thanks for the update! :)

Comment by: Alberto on

Alberto's Gravatar i keep getting the following notice Undefined offset: 1 to 31

"Notice: Undefined offset: 1 in SimpleCalendar.php on line 150"

Comment by: murali on

murali's Gravatar I used this calendar script in my website. I need to have the extended dates of next month and previous month in the current month. Please help me to do it in this calendar script. I would appreciate any help on this.

Thanks.

Comment by: Guilherme on

Guilherme's Gravatar NICE !!! VERY NICE CLASS !

To change the header,

Sun Mon Tue Wed Thu Fri Sat

To other languages ? what should i do ?

Thanks

Guilherme

Comment by: Brad Haizlett on

Brad Haizlett's Gravatar Is there any way to enable previous and next month functionality on it? That would be awesome if you had that, or at least a way to have that working.

Comment by: Jesse G. Donat on

Jesse G. Donat's Gravatar Do you mean just rendering the next/previous month? That's as simple as:
$calendar = new donatj\SimpleCalendar();
$calendar->show(true);

$calendar->setDate('last month');
$calendar->show(true);

$calendar->setDate('next month');
$calendar->show(true);
If you mean button's for next/previous month, thats outside the scope. This is just a little widget to render a calendar. You can write JavaScript or PHP to do it yourself though without too much trouble.

Comment by: Mike on

Mike's Gravatar Any chance to provide code to display weekly view

Comment by: Peter on

Peter's Gravatar Good class! Thank you.

One question, regarding this line:

$out .= "\n" . ($i != $count ? '' : '');

Why did you check ($i != $count?)

In this way, one TR - start is missed.

Br,
Peter

Comment by: Anthony on

Anthony's Gravatar Concerning buttons for next/previous months. I understand you said its outside the scope but it would be really helpful if you could help out with it as its a bit cumbersome when trying to figure out the correct code to do it.

If you have update please put it out there.

Comment by: kalle on

kalle's Gravatar How do you make the calendar show current week only?

Comment by: kalle on

kalle's Gravatar I also get this error when downloaded the latest version.


Parse error: syntax error, unexpected T_STRING in C:\wamp\www\calendar\donatj\SimpleCalendar.php on line 3

Comment by: Greg on

Greg's Gravatar Any way to make it so you can click on a day and have it call a function to set an event for that day?

Comment by: Chris Yates on

Chris Yates's Gravatar Cracking little calendar nice & simple ...
I've incorporated this in a pretty complex ERP system and it works great and is easy to expand on

Comment by: Jose Vivas on

Jose Vivas's Gravatar Can you fill in the blanks with the dates of the previous month and the following month?

Comment by: rassloff on

rassloff's Gravatar thanks for sharing.

Comment by: Mesk on

Mesk's Gravatar Hi, nice work.

How can I make the rendering of events that are date ranges, not individual events, appear as a single event spanning from the first to the last day?

Comment by: Jesse G. Donat on

Jesse G. Donat's Gravatar I'm sorry but that's not a feature of the calendar library.

It would require more a more complicated combination of HTML and CSS than this is designed to generate.

This outputs a reasonably simple table structure. Having events visually span multiple days would probably double if not triple the complexity of the library.

I'm sure there are other libraries that would better suit your needs.

Comment by: Hernan on

Hernan's Gravatar Would be great to have a switch to be able to complete weeks at the start or end of month with days of previous and next months.

Thanks for your work!

Email address will never be publicly visible.

Basic HTML allowed.