I have following datepicker script:
JavaScript
x
12
12
1
<script>
2
$(function(){
3
$("#to").datepicker();
4
$("#from").datepicker().bind("change",function(){
5
var minValue = $(this).val();
6
minValue = $.datepicker.parseDate("mm/dd/yy", minValue);
7
minValue.setDate(minValue.getDate()+1);
8
$("#to").datepicker( "option", "minDate", minValue );
9
})
10
});
11
</script>
12
Now dateformat is MM/DD/YY .how to change the date format to YYYY-MM-DD?
Advertisement
Answer
Use the dateFormat
option
JavaScript
1
10
10
1
$(function(){
2
$("#to").datepicker({ dateFormat: 'yy-mm-dd' });
3
$("#from").datepicker({ dateFormat: 'yy-mm-dd' }).bind("change",function(){
4
var minValue = $(this).val();
5
minValue = $.datepicker.parseDate("yy-mm-dd", minValue);
6
minValue.setDate(minValue.getDate()+1);
7
$("#to").datepicker( "option", "minDate", minValue );
8
})
9
});
10
Demo at http://jsfiddle.net/gaby/WArtA/