Home > Net >  Only allow the last friday in month date picker don´t work for me
Only allow the last friday in month date picker don´t work for me

Time:08-08

I want to enable only the last Friday in each month in my datepicker. In another example I found a code-snippet but it doesn't work for me. Maybe my picker uses other attribute 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

CodePudding user response:

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 )), ''];
    }
});
  • Related