How to get the date from jQuery UI datepicker

user605334 picture user605334 · Feb 7, 2011 · Viewed 213.1k times · Source

I want to get the date from datepicker whenever user choose the date in jQuery UI datepicker and click the button on the form.

well I need to get the day, month and year of the date they choose. How can I get the date form jQuery UI?

Answer

CoolEsh picture CoolEsh · Feb 7, 2011

Use

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();
}