I´m traying to get actual week with fullCalendar
plugin in laravel 5.8
. I need get it, to send this date to controller and to do a query with this date.
In my script.js i have a listener click
but change my view to week and in this view in title put current week in this format:
8 – 14 mar 2021
i want to get firts day of week and last day of week. Also i´m traying with
var currentDate = calendar
var beginOfWeek = currentDate.startOf('week');
var endOfWeek = currentDate.endOf('week');
but returned me:
currentDate.startOf is not a function
because currentData
return empty array... But i´m instaciate my calendar so:
var calendar = new FullCalendar.Calendar(document.getElementById('calendar'), {
headerToolbar: {
left: 'prev next today',
center: 'title',
right: 'dayGridDay dayGridWeek dayGridMonth listMonth'
},
locale: config.lang,
initialView: 'dayGridMonth',
displayEventTime: true,
events: dbEvents,
and i have all my events from DB in my calendar... I don´t understand why i can´t use my object to use startOf
and endOf
.
I don´t know i´m doing well my logic, maybe i should to do this to other form. How can i get current week? and even i want show next or last week that i can get this week ok.
Thanks so much for help, and sorry for my english i hope that you can understand me.
with this function, i´m able to get week´s days
/** GET DAYS OF WEEK */
function getDaysOfWeek(calendar){
if(!calendar) return;
let startDayWeek = calendar.view.activeStart;
let endDayWeek = calendar.view.activeEnd;
var firstDay = new Date(startDayWeek);
var lastDay = new Date(endDayWeek);
dayStartWeek = firstDay.toISOString().substring(0,10);
dayEndWeek = lastDay.toISOString().substring(0,10);
}