日历正在显示,但我必须在下一次和上一次按钮点击时更改日期,但它无效。
我正在使用Bootstrap V3和datetimepicker版本4.15.35 https://github.com/Eonasdan/bootstrap-datetimepicker
这是代码:
ORDER BY "ID"
答案 0 :(得分:0)
我建议您使用moment
操纵日期查看JSFiddle
上的工作示例$('#datetimepicker1').datetimepicker({
format: "MM/DD/YYYY",
defaultDate: new Date()
});
//Next button added to Change date on next button click
$(function() {
$('#next').click(function(event) {
event.preventDefault();
var date = $('#datetimepicker1').data("DateTimePicker").date();
nextdate = moment(date).add(1, 'days');
$('#datetimepicker1').data("DateTimePicker").date(nextdate);
});
});
//Previous button added to Change date on prev button click
$(function() {
$('#previous').click(function(event) {
event.preventDefault();
var date = $('#datetimepicker1').data("DateTimePicker").date();
predate = moment(date).subtract(1, 'days');
$('#datetimepicker1').data("DateTimePicker").date(predate);
});
});