如何在日期选择器中将日期格式(MM / DD / YY)更改为(YYYY-MM-DD)
问题描述:
我有foll0wing datepicker脚本
I have foll0wing 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>
现在日期格式为MM / DD / YY。如何将日期格式更改为YYYY-MM-DD
Now dateformat is MM/DD/YY .how to change the date format to YYYY-MM-DD
答
使用 dateFormat
选项
$(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 );
})
});