I am using this bootstrap-datepicker for my datepicker. I\'d like the datepicker to choose \"today\" for start day or default day. I cannot figure out how to set \"today\"
I used this code
$('#datePicker').datepicker({
format:'mm/dd/yyyy',
}).datepicker("setDate",'now');
This should work:
$("#datepicker").datepicker("setDate", new Date());
And for autoclose (fiddle):
$('#datepicker').datepicker({
"setDate": new Date(),
"autoclose": true
});
jQuery > datepicker API
If none of the above option work, use the following :
$(".datepicker").datepicker();
$(".datepicker").datepicker("setDate", new Date());
This worked for me.
This question is about bootstrap date picker. But all of the above answers are for the jquery date picker. For Bootstrap datepicker, you just need to provide the defaut date in the value of the input element. Like this.
<input class="form-control datepicker" value=" <?= date("Y-m-d") ?>">
Its simple
$(function() {
$("#datePicker").datetimepicker({
defaultDate:'now'
});
});
This will set today as default
Perfect Picker with current date and basic settings
//Datepicker
$('.datepicker').datepicker({
autoclose: true,
format: "yyyy-mm-dd",
immediateUpdates: true,
todayBtn: true,
todayHighlight: true
}).datepicker("setDate", "0");