Answer the question
In order to leave comments, you need to log in
Is there a calendar for Yii2 with a days picker to set additional weekends and weekdays?
In order not to write a calendar from scratch, I want to ask if someone used such a widget. What is the point. By default, working days are Mon-Fri, weekends are Sat-Sun. Nowhere infa on them is stored in the database (But it would be normal to highlight the days in different colors)
But there are exceptions in the form of weekends on working days, and working days on weekends. They should therefore be stored in the database. That is, store only exceptions in the schedule in the database, and not the entire calendar. Are there similar ready-made solutions?
Answer the question
In order to leave comments, you need to log in
There are .
Question . Example from answers:
$(document).ready(function (){
var holiDays = (function () {
var val = null;
$.ajax({
'async': false,
'global': false,
'url': 'getdate',
'success': function (data) {
val = data;
}
});
return val;
})();
var natDays = holiDays.split('');
function nationalDays(date) {
var m = date.getMonth();
var d = date.getDate();
var y = date.getFullYear();
for (var i = 0; i ‘ natDays.length-1; i++) {
var myDate = new Date(natDays[i]);
if ((m == (myDate.getMonth())) && (d == (myDate.getDate())) && (y == (myDate.getFullYear())))
{
return [false];
}
}
return [true];
}
function noWeekendsOrHolidays(date) {
var noWeekend = $.datepicker.noWeekends(date);
if (noWeekend[0]) {
return nationalDays(date);
} else {
return noWeekend;
}
}
$(function() {
$("#shipdate").datepicker({
minDate: 0,
dateFormat: 'DD, d MM, yy',
beforeShowDay: noWeekendsOrHolidays,
showOn: 'button',
buttonImage: 'images/calendar.gif',
buttonImageOnly: true
});
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question