datetimepicker双日历的使用/恢复默认日期
任意选中日期 对应的列表刷新数据 点击重置后 日期框恢复为默认的当前日期
正常使用:
function fnCalendar(id){
$(id).daterangepicker({
autoApply:true,//点击最后时间自动回填数据
"opens": "left",//日历位置
"maxDate":new Date(),
"locale": {
format: 'YYYY-MM-DD',
separator: '~',
daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月',
'七月', '八月', '九月', '十月', '十一月', '十二月' ],
}
}).on('change',function(){
var _model = $(id).attr('data-block');
updownjson.page=1;
updownjson.time_type=$("#event_datetimepicker").val().replace(/\-/g,":");
fnUpDownList();
// $(this).parents('.innerTit').find('.timetype i').removeClass('active');
// _timejson.time_type = $('#event_datetimepicker').val().trim();
// fnPolyline($('.analysis-buutton').find('button.active').attr('data-url'),_timejson);
});
}
点击重置后:
var today=currentdate();
$("#event_datetimepicker").val(today+"~"+today);
//当前时间
function currentdate(){
var date = new Date();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + "-" + month + "-" + strDate;
return currentdate
}