Adding Second Date Format to jQuery UI Date Picker is Not Working

Adding Second Date Format to jQuery UI Date Picker is Not Working

I have to set the datepicker date format like dateFormat: "yy-mm-dd", and this is because I am getting data from database in this format. Now I want to display any changes of datepicker in this format 'DD, d MM, yy' what I did was

 onSelect: function(){ var formattedDate = $('#datepicker').datepicker({ dateFormat: 'DD, d MM, yy' }).val(); alert(formattedDate); }

but the datepicker still returning the data in "yy-mm-dd" format can you please let me know how to fix this?

Demo