I am using the UI DatePicker from jQuery UI as the stand alone picker. I have this code:
And the
inside the jQuery script code just paste the code.
$( ".selector" ).datepicker({ dateFormat: 'yy-mm-dd' });
this should work.
This is what worked for me:
$.fn.datepicker.defaults.format = 'yy-mm-dd'
$("#datepicker").datepicker("getDate")
returns a date object, not a string.
var dateObject = $("#datepicker").datepicker("getDate"); // get the date object
var dateString = dateObject.getFullYear() + '-' + (dateObject.getMonth() + 1) + '-' + dateObject.getDate();// Y-n-j in php date() format
If you need the date in yy-mm-dd format,you can use this:-
$("#datepicker").datepicker({ dateFormat: "yy-mm-dd" });
You can find all the supported format https://jqueryui.com/datepicker/#date-formats
I was in need of 06,Dec 2015,I did this:-
$("#datepicker").datepicker({ dateFormat: "d M,y" });