PHP code example of krzystof / business-calendar

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

    

krzystof / business-calendar example snippets


$calendar = new Calendar($workingWeek, $events, $timezone);

$scheduledTask = $calendar->schedule($task);

$scheduledTask->beginning();
$scheduledTask->end();


$workingWeek->addOpening(new Opening([
    'day' => Carbon::MONDAY, 'time' => '06:00', 'length' => 12 * 3600
]));
$workingWeek->addOpening($opening2);

$workingWeek->countOpenings();           // returns the count of the openings
$workingWeek->isOpenAt(Carbon::now());   // returns bool
$workingWeek->workingHours();            // returns the sum of the working hours of the openings

$workingWeek->addOpenings(FrenchOpeningParser::parse('le lundi de 8h a 18h'));
$workingWeek->addOpenings(EnglishOpeningParser::parse('from Monday to Friday, 9 to 5'));

$ww = new WorkingWeek(FrenchOpeningParser::parse('lun mar mer 7-16'));-->

#### Opening

BusinessTime::dayFromString('Friday');  // returns 5
BusinessTime::dayToString(0);           // returns 'Sunday'
BusinessTime::hoursToSeconds(2);        // returns 7200
BusinessTime::secondsToHours(3600)      // returns 1