minDate从今天开始设置为+3天,最小范围也是3天。昨天一切都很棒,但今天它显示的不是11月3日,而是12月3日。不知怎的,它跳了一个月。有什么问题以及如何解决?
谢谢...
http://jsfiddle.net/ZiNNED/4fa5n7wa/2/
$(document).ready(function () {
var today = new Date();
var minStart = new Date();
minStart.setDate(today.getDate() + 3);
var minEnd = new Date(minStart);
minEnd.setDate(minEnd.getDate() + 3);
$("#start").datetimepicker({
format: "Y/m/d H:i",
dayOfWeekStart: "1",
value: "12:00",
inline: true,
lang: "nl",
onSelectDate: function (ct) {
var diff = CalcDiff();
var minDate = new Date(ct);
minDate.setDate(minDate.getDate() + 3);
if (diff > 72)
var defDate = new Date($("#end").val());
$("#end").datetimepicker("destroy");
$("#end").datetimepicker({
format: "Y/m/d H:i",
dayOfWeekStart: "1",
value: "12:00",
inline: true,
lang: "nl",
minDate: minDate,
defaultDate: defDate || minDate,
onSelectDate: function (ct) {
CalcDiff();
},
onSelectTime: function (ct) {
CalcDiff();
}
}).val(defDate || minDate);
CalcDiff();
},
onSelectTime: function (ct) {
CalcDiff();
},
minDate: minStart,
defaultDate: minStart
}).val(minStart);
$("#end").datetimepicker({
format: "Y/m/d H:i",
dayOfWeekStart: "1",
value: "12:00",
inline: true,
lang: "nl",
minDate: minEnd,
defaultDate: minEnd,
onSelectDate: function (ct) {
CalcDiff();
},
onSelectTime: function (ct) {
CalcDiff();
}
}).val(minEnd);
CalcDiff();
});
function CalcDiff() {
var start = new Date($("#start").val());
var end = new Date($("#end").val());
if (start != null && end != null) { // We have both dates
var hours = Math.round(Math.abs(end - start) / 36e5);
$("#difference").val(hours);
}
return hours;
}