I am using the UI DatePicker from jQuery UI as the stand alone picker. I have this code:
<div id="datepicker"></div>
And the following JS:
$('#datepicker').datepicker();
When I try to return the value with this code:
var date = $('#datepicker').datepicker('getDate');
I am returned this:
Tue Aug 25 2009 00:00:00 GMT+0100 (BST)
Which is totally the wrong format. Is there a way I can get it returned in the format DD-MM-YYYY
?
Finally got the answer for datepicker date change method:
Here is an out of the box future proof date snippet. Firefox defaults to jquery ui datepicker. Otherwise HTML5 datepicker is used. If FF ever support HTML5 type="date" the script will simply be redundant. Dont forget the three dependencies are needed in the head tag.
getDate
function returns a JavaScript date. Use the following code to format this date:It uses a utility function which is built into datepicker:
The full list of format specifiers is available here.
$("#datepicker").datepicker("getDate")
returns a date object, not a string.Try to use the
and there is lots of option available For the datepicker you can find it Here
This is the way we call the datepicker with the parameter
you can simply use this format in you function just like