1 <script type="text/javascript"> 2 var ctx = '${ctx}'; 3 $(function () { 4 //var currYear = (new Date()).getFullYear(); 5 //var currMonth = (new Date()).getMonth(); 6 var date = new Date(); 7 var opt={}; 8 opt.date = {preset : 'date'}; 9 //opt.datetime = { preset : 'datetime', minDate: new Date(2012,3,10,9,22), maxDate: new Date(2014,7,30,15,44), stepMinute: 5 }; 10 opt.datetime = {preset : 'datetime'}; 11 opt.time = {preset : 'time'}; 12 opt.default = { 13 theme: 'android-ics light', //皮膚樣式 14 display: 'modal', //顯示方式 15 dateFormat:'yyyy-mm', 16 dateOrder:'yyyymm', 17 mode: 'scroller', //日期選擇模式 18 lang:'zh', 19 //startYear:currYear - 20, //開始年份 20 //endYear:currYear, //結束年份 21 minDate: new Date(date.getFullYear(),date.getMonth()-6), 22 maxDate:new Date(date.getFullYear(),date.getMonth()+6), 23 onCancel:function(){//點擊取消按鈕 24 $('#appDate').val("");//清空時間 25 }, 26 onSelect:function(){//點擊確定按鈕 27 search(); 28 }, 29 }; 30 31 var time = $.extend(opt['date'], opt['default']); 32 $("#appDate").val('').scroller('destroy').scroller($.extend(opt['date'], opt['default'])); 33 }); 34 </script>
控制時間顯示為當前時間的前6個月和后6個月
<input type="text" name="" placeholder="點擊選擇時間" class="time" id="appDate" />