FullCalendar.io component for Yii2
$ php composer.phar require adlurfm/yii2-fullcalendar-2
or add
"adlurfm/yii2-fullcalendar-2": "dev-main"
to the require
section of your composer.json
file.
//View File
<?= FullCalendar::widget([
'id' => 'calendar',
'clientOptions' => [
'initialDate' => date('Y-m-d'),
'timeZone'=>'Asia/Kuala_lumpur',
'weekNumbers' => true,
'selectable' => true,
'initialView' => 'timeGridWeek',
'events' =>Url::to(['site/events']),
'eventTimeFormat'=> [ // like '14:30'
'hour'=>'2-digit',
'minute'=>'2-digit',
'meridiem' => false,
'hour12'=> false
]
],
]); ?>
//Controller File - Return as JSON format
public function actionEvents($start, $end)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return [
[
'title'=>'All Day Event',
'start'=>'2023-01-01'
],
[
'title'=>'Long Event',
'start'=>'2023-01-04',
'end'=>'2023-01-11'
],
];
//Read more about event at https://fullcalendar.io/docs/event-parsing
}
Read more options at - fullcalendar.io