如何在日期选择器中将日期格式 (MM/DD/YY) 更改为 (YYYY-MM-DD)

问题描述:

我有以下日期选择器脚本:

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> 

现在日期格式是 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 );
        })
    });

演示在 http://jsfiddle.net/gaby/WArtA/