最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Easepick - preset startDate and endDate | save values in variables - Stack Overflow

programmeradmin1浏览0评论

I would like to use the datepicker easepick.

I would like to preset a date range: current date (=startDate) and current date + 2 years (=endDate). This date range should be shown in the field.

Then the user should be able to pick his own date range.

And at last step I would like to get the startDate and the endDate (eather the preset dates or if given the ones chosen by the user) and save it in a variable. If the user changes his date range the variables should update too.

const picker = new easepick.create({
    element: document.getElementById('datepicker'),
    css: [
    '/@easepick/[email protected]/dist/index.css',
    ],
    calendars: 2,
    grid: 2,
    setup(picker) {
           picker.on('select', (e) => {

           });   
    },
    plugins: ['LockPlugin','RangePlugin'],
    LockPlugin: {
    minDate: new Date(),
    },
    RangePlugin: {
    tooltip: true,
    startDate: new Date(),
    endDate: new Date().add(2, 'years');,
    locale: {
        one: 'day',
        other: 'days',},
    },    
});

var startDate = picker.getStartDate().format('YYYY-MM-DD');
var endDate = picker.getEndDate().format('YYYY-MM-DD');

Thank you in advance for your help!

发布评论

评论列表(0)

  1. 暂无评论