Tempus-dominus: minDate overrides DefaultDate

Created on 27 Apr 2016  路  5Comments  路  Source: Eonasdan/tempus-dominus

Using an example of MinDate = '2016-05-11' and DefaultDate = '2016-05-18' ....

I simply cannot make the date go to Default not matter what I try. It is always overridden by minDate

'YYYY-MM-DD' wasn't even my first choice of date format. I wanted 'dd MMM yyyy' but that had the same problem.

As you can see I even try and set the date to the default after creation. Still no luck.

$('#DesiredDate').datetimepicker({
            minDate: '@ViewBag.MinDate',
            defaultDate: '@ViewBag.DefaultDate',
            maxDate: '@ViewBag.MaxDate',
            format: 'YYYY-MM-DD',
            showClose: false,
            showClear: false,
            toolbarPlacement: 'top'
        });
$('#DesiredDate').datetimepicker('date','@ViewBag.DefaultDate');

Most helpful comment

@benbhale check setting: useCurrent: false
For me it's working pretty cool.
Let me know.

All 5 comments

p.s. if I drop minDate from the definition, then the defaultDate gets picked up. So it's definitely a comparison issue.

+1 the same here
It's really important bug, now this lib is unuseful for me.

PS Why there are so many open issues there?

@benbhale check setting: useCurrent: false
For me it's working pretty cool.
Let me know.

I noticed that the defaultDate got picked up the second time the DateTimePicker is shown, so I sloved the bug with calling
$el.datetimepicker('show'); $el.datetimepicker('hide');

As @r3m4k3 mentioned, I was able to workaround this issue by explicitly setting the useCurrent option to false e.g.

$( '#DesiredDate' ).datetimepicker({
    useCurrent: false,
    defaultDate: moment({hour: 19}).add(1, 'day'),
    minDate: moment()
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

justqyx picture justqyx  路  3Comments

woohling picture woohling  路  4Comments

ravindrabr picture ravindrabr  路  6Comments

dleffler picture dleffler  路  4Comments

am11 picture am11  路  6Comments