0
votes

I set the minDate(2019-06-21) and maxDate(today) when initialize the "From" and "To" datetimepickers. When select time interval to month, Will format the datetimepicker to "MMM YYYY". Then I only can select Jul in the calendar widget although the Jun is also active and should be selectable.

But if I add "useCurrent: false" in the datetimepicker initialization code, the calendar will allow user to select Jun only but not Jul.

code is here:

enter code here
 https://jsfiddle.net/srcuz3fm/

Since the minDate is Jun 21, 2019 and maxDate is today(7/23/2019), it should all user to select either Jun or Jul from the calendar widget no matter the useCurrent is true or false.

1

1 Answers

0
votes

After days of trys, I figures out how to fix this issue. BAsically, the reason cause the problem is when change datetimepicker format, it'll set the year to the morning midnight of new year day. Since I set the minDate in the initial settings which is "2019-06-21", so the datetimepicker won't allow me to select 2019.

So I added these in the javascript together right before the format,

$("#datetimepicker2").datetimepicker("minDate", moment(startdate).startOf("year")); $("#datetimepicker3").datetimepicker("minDate", moment(startdate).startOf("year")); $("#datetimepicker2").datetimepicker("maxDate", moment(today).endOf("year")); $("#datetimepicker3").datetimepicker("maxDate", moment(today).endOf("year"));

Here is the link to working code in jsfiddle