datepicker get date code example

Example 1: datepicker get selected date

$(function() {
    $("#datepicker").datepicker();
    
    $("#datepicker").val();
    
    $("#datepicker").on("change",function(){
        var selected = $(this).val();
        alert(selected);
    });
});

Example 2: jquery get date from datepicker

var jsDate = $('#your_datepicker_id').datepicker('getDate');
if (jsDate !== null) { // if any date selected in datepicker
    jsDate instanceof Date; // -> true
    jsDate.getDate();
    jsDate.getMonth();
    jsDate.getFullYear();
}