I have a problem with dateFormat when it is in function beforeShowDay.
I am using datapicker jQuery DataPicker from https://api.jqueryui.com/datepicker/.
I would like it to check the dates and change the colors. I set the dataPicker dataFormat,but not working. When is mm-dd-yy then it working, but I wish it would work when it's set yy-mm-dd. how can I fix it? This is my script:
<style>
.event a {
background-color: lightgreen !important;
color: #ffffff !important;
}
</style>
<script>
$( function() {
var eventDates = {};
eventDates[ new Date( '2020-11-09' )] = new Date( '2020-11-09' ); //this not working
eventDates[ new Date( '2020-11-10' )] = new Date( '2020-11-10' ); //this not working
eventDates[ new Date( '11-09-2020' )] = new Date( '11/09/2020' ); //this working
eventDates[ new Date( '11-10-2020' )] = new Date( '11/10/2020' ); //this working
$( "#datepicker" ).datepicker({
dateFormat: 'yy-mm-dd',
altField: "#alternate",
altFormat: "yy-mm-dd",
beforeShowDay: function( date ) {
var highlight = eventDates[date];
if( highlight) {
return [true, "event", 'Text'];
}
else {
return [true, '', ''];
}
}
});
} );
</script>