Download the PHP package garkavenkov/calendar without Composer
On this page you can find all versions of the php package garkavenkov/calendar. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package calendar
Сalendar
Calendar
Installation
Use Composer
composer require garkavenkov/calendar
Usage
Initialization
This code creates calendar based on current date. If you need to create calendar on particular month and year, pass parameters to class constructor
By default calendar creates with week begins on Sunday. If you need week begin on Monday, pass next parameter to class constructor
Also you can set language for day's and month's names. In this you need to pass additional parameter to constructor
Calendar structure
To get calendar use command:
The calendar has the following structure:
Methods
getCalendarBoundaries($format)
If you need to get calendar first and last day, use folowing code:
This method returns an array of calendar start and end dates
You can pass $format variable into method.
With this format methods will return array with formated date
getMonthBoundaries($format = null)
Method getMonthBoundaries()
returns array with first and last day of the calendar month
Likewise getCalendarBoundaries()
you can pass a $format
variable to a method and get the formatted dates
getWeekdays()
Method getWeekdays()
returns an array containing the names of the days of the week.
getMonths()
Method getMonths()
returns an array containing the names of the months.
injectIntoDay(string \$title, array $events, string $array_function)
This method allows to inject data into a day with particular $title
. For example, there is a set of data $events
containing date and some information e.g.
Following code will inject this dataset into calendar with title todos
output
It is also possible to pass $array_function
to perform operation with dataset in $events
.
Following code will inject this result of count
function performed on dataset into calendar with title todos
output
getWeeksNumbers()
This method returns an array containing calendar's weeks numbers.
output
getWeek(int $number)
This method returns an array containing calendar's week by number $number
.
output
getCalendarInfo(string $dateFormat = null)
This method returns an array containing basic information about calendar, i.e. month, year, calendar's and month's boundries
output
It is possible to output calendar's and month's boundries in particular format. To do this, you need to pass a parameter with the necessary format
output
getDay(string $date)
This method returns an array containing particular day information
output