Reputation: 421
Datetimepicker unable select today's date.Suppose When we open the datetimepicker and change the date and select the today date it is not selected.And we used the Bootstarp datetimepicker.
$('#datetimepicker1').datetimepicker().data("DateTimePicker").options({format: "DD/MM/YYYY",minDate:new Date()});
Thank you.
Upvotes: 5
Views: 8439
Reputation: 2732
You just need to pass the date as a string and the rest will be handled by the library itself
moment().format('YYYY/MM/DD')
or
new Date().toDateString()
Upvotes: 0
Reputation: 1238
You're setting the minDate to today, which means won't be able to select it.
Instead, set minDate to
minDate: moment().millisecond(0).second(0).minute(0).hour(0)
which will be today. for more info : https://github.com/Eonasdan/bootstrap-datetimepicker/issues/1302#issuecomment-141923309
Upvotes: 3
Reputation: 61
You have to integrade use Below code to select the todaydate
minDate: new Date().setHours(0,0,0,0)
$("#startdatetimepicker").datetimepicker({ minDate : new Date().setHours(0,0,0,0),format: 'DD-MM-YYYY'});
Upvotes: 6
Reputation: 7765
You're setting the minDate
to today, which means won't be able to select it.
Instead, set minDate
to minDate: moment().subtract(1,'d')
which will be yesterday.
Upvotes: 0
Reputation: 1697
You should use following code.
<script src="/assets/js/plugins/datetime/bootstrap-datetimepicker.min.js"></script>
$('#datetimepicker1').datetimepicker({
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
minView: 2,
forceParse: 0
});
Upvotes: 0
Reputation: 4621
You are setting the minData
to new Data()
new Data()
by default gives the current data.
So In your case you are not able to select not only today's date but all the past date.
So simple remove the minData
parameter(as below), or use it a different way.
$('#datetimepicker1').datetimepicker().data("DateTimePicker").options({format: "DD/MM/YYYY"});
Upvotes: 1