I use jQuery UI DatePicker and was able to disable weekends and holidays there (custom list). Now I need to count the number of working days in a month without taking into account the days off before the selected date.
That is, I choose January 20. 1-8 numbers and 14-15 are non-working. I need to count the rest. Please tell me exactly how I can do this.
I only understood how to calculate the days between two dates. But this is absolutely not the case.
let dt1 = new Date(fromdate);
let dt2 = new Date(todate);
let time_difference = dt2.getTime() - dt1.getTime();
let result = time_difference / (1000 * 60 * 60 * 24);
2
Answers
Sorry it took so long and thanks for your response. It's obvious and that's not what I was asking, but still.
This is the function I got:
Launch this function using the method:
Example:
jQuery UI takes saturday = 6 and sunday = 0 as numeric value. SO you can ignore that numeric value inside for loop to calculate number of days.
Example: