简体   繁体   中英

daterangepicker is custom range

I have ranges applied in my config so user can choose between these predefined dates and click on custom to select custom range:

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')]
    },

I am wondering is there a way to detect whether a custom range has been selected in daterangepicker? I was hoping some such option but I dont see this in options list.

$('INPUT_DIV_ID').data('daterangepicker').chosenLabel

This returns the selected label from the dropdown presets just change the INPUT_DIV_ID to whatever you have named it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM