如何设置最大日期
how to set a max date
<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>
设置日期范围:
$('#date_tim').appendDtpicker({
maxDate : '2016/11/10',
minDate: '2016/09/10'
});
要设置日期,您可以使用以下代码:
$('#date_tim').handleDtpicker('setDate', new Date(2016, 09, 10, 0, 0, 0));
您需要在新 Date();
中提及要设置的任何日期和时间
定义无硬编码的 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));
};
<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>
设置日期范围:
$('#date_tim').appendDtpicker({
maxDate : '2016/11/10',
minDate: '2016/09/10'
});
要设置日期,您可以使用以下代码:
$('#date_tim').handleDtpicker('setDate', new Date(2016, 09, 10, 0, 0, 0));
您需要在新 Date();
定义无硬编码的 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));
};