daterangepicker

    //初始化
var now = $.now(); var lastTime = now - 3600000 * 24*30;// 最近3小时 //var nowDate = new Date(now).format("yyyy-MM-dd HH:mm:ss"); var nowDate = new Date(now).format("yyyy-MM-dd HH:mm:ss"); var lastDate = new Date(lastTime).format("yyyy-MM-dd HH:mm:ss"); var inittime = lastDate + " - " + nowDate; $('#console_time').val(inittime); $('#console_time').daterangepicker({ timePicker: true, timePickerIncrement: 5, timePicker12Hour: false, format: 'YYYY-MM-DD HH:mm:ss' // format: 'YYYY-MM-DD HH:mm:ss' })
//近半年
$(document).on("click","#halfYear",function(e){
    $(this).addClass('choice_active').siblings().removeClass('choice_active');
    //设置初始加载时,时间的显示
    var now = $.now();
    var lastTime = now - 3600000 * 24*30*5;
    var endTime = new Date(now).format("yyyy-MM-dd HH:mm:ss");
    var startTime = new Date(lastTime).format("yyyy-MM-dd HH:mm:ss");
    var inittime = startTime + " - " + endTime;
    
    $("#console_time").val(inittime);
    e.stopPropagation();
    return false;
    
})
原文地址:https://www.cnblogs.com/zjpzjp/p/7575602.html