<script>
$(function () {
var intimepicker = $('#intimerange').daterangepicker({
timePicker: true,
timePickerIncrement: 1,
timePicker24Hour: true,
timePickerSeconds: true,
startDate: moment().startOf('day'),
endDate: moment().endOf('day'),
showSecond: true,
ranges: {
'今天': [moment().startOf('day'), moment().endOf('day')],
'昨天': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
'最近7天': [moment().subtract('days', 6).startOf('day'), moment().endOf('day')],
'最近30天': [moment().subtract('days', 29).startOf('day'), moment().endOf('day')],
'本月': [moment().startOf('month'), moment().endOf('month')],
'上月': [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')]
},
locale: {
format: 'YYYY-MM-DD HH:mm:ss',
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
firstDay: 1,
applyLabel: "应用",
cancelLabel: "取消",
customRangeLabel: '自定义',
separator : '~',
},
});
intimepicker.on('apply.daterangepicker',function(ev, picker) {
t = $('#intimerange').val().split("~");
var begintime = t[0];
var endtime = t[1];
console.log(begintime, endtime);
});
});
</script>
<!-- Date and time range -->
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">时间:</span>
</div>
<input type="text" class="form-control float-right" id="intimerange"
onclick="customRangeLabelan()" readonly="readonly" style="background: transparent;">
</div>
</div>
<!-- Date and time range -->