Datepicker突出显示日期

I've been searching the ways to highlight a date in Datepicker. More or less I've got it, but I'm encountering some problems.

I'm using PHP and the latest version of datepicker plugin.

Here is my code, I've commented it to a better comprehension.

$(document).ready(function() {
    var SelectedDates = {}; //An array that will have the dates to highlight
    <?php
        $events = obtain_events(); //function to obtain all events
        foreach($events as $e) {
        ?>
            SelectedDates[new Date('<?php echo create_date_events($e['Data']); ?>')] = new Date('<?php echo create_date_events($e['Data']); ?>'); 
//this function, create_date_events(), puts the mysql date to mm/dd/yyyy
        <?php
        }
    ?>
    $('#datepicker').datepicker({
        beforeShowDay: function(date) {
            var Highlight = SelectedDates[date];
            if(Highlight) {
                return [true, 'HighlightedCSS', Highlight];
            }
            else {
                return [true, '', ''];
            }
        }
    });
});

The thing is that when runs, it says an error that has no method 'replace'. This was an example I've found and saw other sources that goes like this.

I would appreciate any help! Thank you!!

P.S: I've seen the source, and dates goes out properly