creating custom range label in daterangepicker

时间:2017-05-16 09:31:14

标签: javascript php daterangepicker

I want to set Last Year date like this on daterangepicker : 01-04-2015 - 01-04-2016 But i'm getting output like this: 01-01-2016 - 31-12-2016 here is my code(JS) :

$('.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);

0 个答案:

没有答案