Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 )), ''];
    }
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading