Joh*_*Ken 49 javascript jquery calendar jquery-ui
我有foll0wing datepicker脚本
<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>
Run Code Online (Sandbox Code Playgroud)
现在dateformat是MM/DD/YY.如何将日期格式更改为YYYY-MM-DD
Gab*_*oli 59
使用该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 );
})
});
Run Code Online (Sandbox Code Playgroud)
演示http://jsfiddle.net/gaby/WArtA/
Gaz*_*ion 35
请尝试以下方法:
$('#to').datepicker({
dateFormat: 'yy-mm-dd'
});
Run Code Online (Sandbox Code Playgroud)
你会认为它会是yyyy-mm-dd但是很好:P
Shi*_*iko 22
我有同样的问题,我尝试了很多答案,但没有任何效果.
我尝试了以下内容并成功运行:
<input type=text data-date-format='yy-mm-dd' >
Run Code Online (Sandbox Code Playgroud)
小智 7
$( ".selector" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );
Run Code Online (Sandbox Code Playgroud)
请参阅:http: //jqueryui.com/demos/datepicker/ 和 http://docs.jquery.com/UI/Datepicker/formatDate#utility-formatDate
| 归档时间: |
|
| 查看次数: |
339293 次 |
| 最近记录: |