Javascript 在daterangepicker中创建自定义范围标签
我想在daterangepicker上设置去年的日期:Javascript 在daterangepicker中创建自定义范围标签,javascript,php,daterangepicker,Javascript,Php,Daterangepicker,我想在daterangepicker上设置去年的日期:01-04-2015-01-04-2016 但我得到的输出是这样的:01-01-2016-31-12-2016 以下是我的代码(JS): 从未使用过它,但可能是moment().subtract(1,'年').startOf('月'),moment().startOf('月')?它返回的是:01-05-2016-01-05-2017@splash58这很明显moment().subtract(2,'年').subtract(1,'月').st
01-04-2015-01-04-2016
但我得到的输出是这样的:01-01-2016-31-12-2016
以下是我的代码(JS):
从未使用过它,但可能是
moment().subtract(1,'年').startOf('月'),moment().startOf('月')
?它返回的是:01-05-2016-01-05-2017
@splash58这很明显moment().subtract(2,'年').subtract(1,'月').startOf('月'),moment().subtract(1,'年').subtract(1,'月')
$('.datepikerdemo').daterangepicker({
locale: {
format: 'DD-MM-YYYY'
},
"autoApply": true,
"startDate": $('#from_date').val(),
"endDate": $('#to_date').val(),
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
'Last Year': [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')]
}
}, cb);