Calendar Library written in PHP
require('vendor/autoload.php');
use Carvefx\Calendar\Calendar;
$calendar = new Calendar(2014, 8);
foreach($calendar->getWeeks() as $week) {
foreach($week->getDays() as $day) {
$day->toDateString(); // 2014-07-27
$day->isBlankDay(); // true
}
}
Calendar comes with 3 main classes:
- Calendar: represents a display of the current month, including the blank days that belong to the previous or next months
- Week: represents 7 days, regardless of the month it belongs to
- Day: represents a single day and wraps around the \Carbon\Carbon class
$day = new Day(2014, 07, 01);
$day->setBlankDay(false);
$day->isBlankDay(); // returns a bool value, shows whether the current day is part of the current month
// Any of the \Carbon\Carbon methods work
$day->getDateString(); // 2014-07-01
$day->month; // 7
$first_day = new Day(2014, 07, 01);
$week = new Week($first_day); // constructor requires the day the week starts at
$week->getDays(); // will result in an array containing 7 Day objects
$calendar = new Calendar(2014, 8);
$calendar->setYear(2015);
$calendar->setMonth(7);
$calendar->getFirstDay(); // returns the first day of the month
$calendar->getLastDay(); // returns the last day of tyhe month
$calendar->getWeeks() // results in a number of Week objects