PHP code example of omnicolor / calendar

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

    

omnicolor / calendar example snippets




declare(strict_types=1);

use Carbon\CarbonImmutable as Date;
use Omnicolor\Calendar\Calendar;

// Create a calendar for January 2080.
$calendar = new Calendar(new Date('2080-01-01'), new Date('2080-01-31'));

// Add some random journal entries.
$calendar[new Date('2080-01-01')] = (object)[
    'description' => 'Feeling rather tired after the New Years party.',
    'mood' => 3,
];
$calendar[new Date('2080-01-02')] = (object)[
    'description' => 'Starting the new year off with a job opportunity. '
        . 'The pay looks promising.',
    'mood' => 10,
    'potentialPay' => 20000,
];
$calendar[new Date('2080-01-08')] = (object)[
    'description' => 'Should have known there would be a double-cross. '
        . 'Not only did we not get paid, but we lost three hundred!',
    'mood' => 1,
    'pay' => -300,
];

foreach ($calendar as $date => $entry) {
    // Render calendar however you see fit. If a $date
    // doesn't have an entry, $entry will be null.
}