pwt.datepicker icon indicating copy to clipboard operation
pwt.datepicker copied to clipboard

How to select default Year and month for range date picker?

Open amirkian opened this issue 2 years ago • 0 comments

we have such definition for range selector. Range Selector that make sure 'to' date is after 'from' date and also 'from' is before 'to' date.

var to, from;
to = $(".range-to-example").persianDatepicker({
    inline: true,
    altField: '.range-to-example-alt',
    altFormat: 'LLLL',
    initialValue: false,
    onSelect: function (unix) {
        to.touched = true;
        if (from && from.options && from.options.maxDate != unix) {
            var cachedValue = from.getState().selected.unixDate;
            from.options = {maxDate: unix};
            if (from.touched) {
                from.setDate(cachedValue);
            }
        }
    }
});
from = $(".range-from-example").persianDatepicker({
    inline: true,
    altField: '.range-from-example-alt',
    altFormat: 'LLLL',
    initialValue: false,
    onSelect: function (unix) {
        from.touched = true;
        if (to && to.options && to.options.minDate != unix) {
            var cachedValue = to.getState().selected.unixDate;
            to.options = {minDate: unix};
            if (to.touched) {
                to.setDate(cachedValue);
            }
        }
    }
});

<div class="range-from-example"></div>
<div class="range-to-example"></div>

but all the time it shows current datetime by default which I want to show a specific day. I am looking forward a way to set wanted day.

amirkian avatar Nov 29 '22 17:11 amirkian