How To Change Date Format In Jquery UI Datepicker




Here we consider how to change the Date Format In Jquery UI Datepicker. Suppose the TextBox ID be txtDatePicker. Then Jquery DatePicker can be applied as follows.

$(function() {
          $( "#txtDatePicker" ).datepicker();
});



That's all, if you click on the TextBox, you can see the Jquery Datepicker on the Browser. Here we have not yet applied any Date Format for this Datepicker. For adding Date Format, add following code.

$(function() {
          $( "#txtDatePicker" ).datepicker({ dateFormat: 'dd-mm-yy' });
});



For getting value from Datepicker, get value as follows.

$(function() {
          var date = $('#txtDatePicker').datepicker({ dateFormat: 'dd-mm-yy' }).val();
});


You can make the date format from dd-mm-yy as per your requirement.