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
?
Below code might help to check if form got more than 1 date field:
I think the correct way to do this would be something like this:
This way you make sure the format string is defined only once and you use the same formatter to translate the format string into the formatted date.
you should use
data-date-format="yyyy-mm-dd"
in your input field html and initial data picker in JQuery just like simpleHere complete code for date picker with date format (yy/mm/dd).
Copy link below and paste in head tag :
Copy below code and paste between body tag :
If you would like two(2) input type text like
Start Date
andEnd Date
then use this script and change date format.Two input text like :
Here's one specific for your code:
More general info available here: