I have following datepicker script:
<script> $(function(){ $("#to").datepicker(); $("#from").datepicker().bind("change",function(){ var minValue = $(this).val(); minValue = $.datepicker.parseDate("mm/dd/yy", minValue); minValue.setDate(minValue.getDate()+1); $("#to").datepicker( "option", "minDate", minValue ); }) }); </script>
Now dateformat is MM/DD/YY .how to change the date format to YYYY-MM-DD?
var year = 2014; var month = 5; var day = 10; var realDate = new Date(year, month - 1, day); // months are 0-based! $('#MainContent_txtDataConsegna'). datepicker({ dateFormat: 'dd/mm/yyyy' }); // format to show $('#MainContent_txtDataConsegna'). datepicker('setDate', realDate);
$("#from-datepicker"). datepicker({ dateFormat: 'yy-mm-dd'}); $("#from-datepicker"). on("change", function () { var fromdate = $(this). val(); alert(fromdate); });
Click the Date Picker Control in the Controls group. Click Properties in the Controls group. Click inside the Title text box and enter End Date:. In the Display The Date Like This list box, select the desired date format and then click OK.
Use the dateFormat
option
$(function(){ $("#to").datepicker({ dateFormat: 'yy-mm-dd' }); $("#from").datepicker({ dateFormat: 'yy-mm-dd' }).bind("change",function(){ var minValue = $(this).val(); minValue = $.datepicker.parseDate("yy-mm-dd", minValue); minValue.setDate(minValue.getDate()+1); $("#to").datepicker( "option", "minDate", minValue ); }) });
Demo at http://jsfiddle.net/gaby/WArtA/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With