PHP code example of seebaermichi / monthly-calendar

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

    

seebaermichi / monthly-calendar example snippets


// Will return an array with the given months and their weeks and days
// weeks will start with Monday
$monthlyCalendar = new Seebaermichi\MonthlyCalendar(['December 2021', 'January 2022']);
$calendar = $monthlyCalendar->getCalendar();

// Will return an array with the given months and their weeks and days
// weeks will start with Sunday
$monthlyCalendar = new Seebaermichi\MonthlyCalendar(['February 1989', 'March 1989'], 'Sun');
$calendar = $monthlyCalendar->getCalendar();

// Provide simple array of events and event label to get related days labeled
// First of December will have an event attribute 'birthday'
$monthlyCalendar = new Seebaermichi\MonthlyCalendar(['December 2021']);
$calendar = $monthlyCalendar->getCalendar(['2021-12-01'], 'birthday');

// Provide array of events with detailed data to get related days labeled
// 6th of March 2023 will have an events array including the given data
$monthlyCalendar = new Seebaermichi\MonthlyCalendar(['December 2021']);
$givenEvents = [
    [
        'datetime' => '2023-06-03 10:00',
        'label' => 'meeting',    
    ],
    [
        'datetime' => '2023-06-03 13:00',
        'label' => 'lunch',    
    ],
];
$calendar = $monthlyCalendar->getCalendar($givenEvents, '', 'Y-m-d H:i');

// Get only weekdays array with optional $startWith day
$weekdays = Seebaermichi\MonthlyCalendar::weekdays(); // ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
$weekdays = Seebaermichi\MonthlyCalendar::weekdays('Sun'); // ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']