I want to enable only the last friday in each month in my datepicker. In another example I found a code-snippet but this dont work for me. Maybe my tracker use other atribute-names?!
How I can do this?
var monthDays = new Date(date.getFullYear(),date.getMonth() + 1,0).getDate(); var day = date.getDay(); return [( (day==5 && date.getDate() > monthDays - 7 )), '']; }
Here is the codepen for the tracker
Thanks a lot!
Chris
>Solution :
Your snippet is correct, but you need to place it in the constructor like this:
jQuery('#datetimepicker').datetimepicker({
allowTimes:[
'10:00', '11:00', '12:00','14:00'
],
beforeShowDay: function(date) {
const monthDays = new Date(date.getFullYear(),date.getMonth() + 1,0).getDate();
const day = date.getDay();
return [( (day==5 && date.getDate() > monthDays - 7 )), ''];
}
});