<script type="text/javascript" src="<?php echo theme_js('jquery.simple-dtpicker.js')?>"></script>
<link type="text/css" href="<?php echo theme_css('jquery.simple-dtpicker.css')?>" rel="stylesheet" />
<script type="text/javascript">
var now = new Date();
var yourDate = now.getDate() + '/' + (now.getMonth() + 3) + '/' + now.getFullYear();
//alert(today);
$('#date_tim').appendDtpicker({
"futureOnly": true,"autodateOnStart": false,"setDate": yourDate,"minTime":"10:00","maxTime":"18:00","closeOnSelected": true
});
</script>
答案 0 :(得分:0)
设置日期范围:
$('#date_tim').appendDtpicker({
maxDate : '2016/11/10',
minDate: '2016/09/10'
});
要设置日期,您可以使用以下代码:
$('#date_tim').handleDtpicker('setDate', new Date(2016, 09, 10, 0, 0, 0));
您需要在新的Date();
答案 1 :(得分:0)
无需硬编码即可定义Maxdate:-
function dateP() {
var today = new Date();
$(".datepicker").datepicker({
dateFormat: "dd/mm/yy",
maxDate: "-1d"
});
$(".datepickerYesterday").datepicker({
dateFormat: "dd/mm/yy",
maxDate: "-1d"
}).datepicker("setDate", -1);
$('.datepickerMonthlyReport').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
maxDate: "-1M",
dateFormat: 'mm/yy',
onChange: function(dateText, inst) {
$(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
},
beforeShow: function(el, dp) {
$('#ui-datepicker-div').addClass('hide-calendar');
},
onClose: function(dateText, inst) {
$('#ui-datepicker-div').removeClass('hide-calendar');
$(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
}
}).datepicker("setDate", new Date(today.getFullYear(), today.getMonth() - 1, 1));
};