R.Shaw
R.Shaw

Reputation: 23

Query fullCalendar dayClick - convert (date) to HH.MM

I want the time will be selected when clicking on timeslot of a day in fullclendar. i.e, if i click on 9.00am - 9.30am slot, i want both time. this is my code:-

$('#calendar').fullCalendar({
            allDayDefault: false,
            dayClick: function(date, allDay, jsEvent, view){
                popupopen = 1;
                var clickedTime = 'Clicked on: ' + date.format();
});

Now, if i click 10.00 am,this gives:- Clicked on: 2016-07-19T10:00:00. But, i only want,10.00. How to get that? And also when i click on 10.00 -10.30 slot, how to get both time?

Upvotes: 1

Views: 1316

Answers (1)

user6269864
user6269864

Reputation:

For your first question: date is a moment.js object, so just use moment.js methods.

var clickedTime = date.format("h:mm a");

As for getting the second date, I can only think of setting it manually using slotDuration and then since you will know this value, you can add it to the start date.

E.g. in my calendar the slotDuration is 1 hour, so I would do date.add(1, 'hours');

Upvotes: 1

Related Questions