John Cliven
John Cliven

Reputation: 1231

FullCalendar.js - 7 days only (no actual dates)

I'm setting a weekly scheduling system which is not linked to actual dates, but rather days in the week. So Monday-Sunday.

I've achieved this in FullCalendar using the following:

defaultView: 'basicWeek',
columnFormat: 'ddd',

However I now have issues displaying the events that are read from my DB, as I can only get FullCalendar to display dates that are in a standard full date format.

My options are:

1) Set an invisible date range (Eg, 2017-01-01 - 2017-01-07) and save all events within this range (invisible to the user but operational on backend)

2) Try and store the dates as Mon/Tue/Wed and load natively into FullCalendar

I'm aiming for the 2nd!

Upvotes: 2

Views: 1161

Answers (1)

VikingCode
VikingCode

Reputation: 1052

you can use the getDay() function to get the day of the week. (int)

The getDay() method returns the day of the week (from 0 to 6) for the specified date.
Note: Sunday is 0, Monday is 1, and so on. - w3schools

Example:

var d = new Date('2017-04-26');
var n = d.getDay();  
alert(n); // will be 3 => Wednesday

Upvotes: 1

Related Questions