Working on a problem, and the formatting of the dateFormat is not working as It thought it would. Can anyone see anything that stands out? It works if I change the date to a different format
var check_in = [["25/11/2021", "28/11/2021"]];
if ($(window).width() > 700) {
$('#arrival, #contact-arrival').datepicker({
minDate: '0M',
numberOfMonths: 2,
beforeShowDay: function(date) {
var string = jQuery.datepicker.formatDate('d/m/yy', date);
for (var i = 0; i < check_in.length; i++) {
if (Array.isArray(check_in[i])) {
var from = new Date(check_in[i][0]);
var to = new Date(check_in[i][1]);
var current = new Date(string);
if (current >= from && current <= to) return false;
}
}
return [check_in.indexOf(string) == -1]
},
dateFormat: 'dd M yy',
onSelect: function (dateText, inst) {
$('#departure, #contact-departure').datepicker("option", "minDate", dateText);
}
});
In the above script, the jQuery.datepicker.formatDate('d/m/yy', date);
is not recognizing var check_in = [["25/11/2021", "28/11/2021"]];
If I change the code to var string = jQuery.datepicker.formatDate('d/M/yy', date);
and the format of the array to var check_in = [["25/Nov/2021", "28/Nov/2021"]];
Everything works, but the data is being pulled in the first format 1/1/2021
Hope someone with a fresh pair of eyes can see what I am doing wrong.
Many thanks.