Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Current Date as Selected in Bootstrap datepicker

I am using bootstrap-datepicker in my code. How Do I select current date in JavaScript and show it as selected?

After research this is code I am using but current day does not appear as selected:

var today = moment();

datepicker1.datepicker({
    endDate: today.toDate()
}); 

datepicker2.datepicker({
    startDate: today .toDate(),
    endDate: today.toDate()
});

datepicker1.datepicker('setDate', today.toDate());
datepicker2.datepicker('setDate', today.toDate());

datepicker1.datepicker('update');  //update the bootstrap datepicker
datepicker2.datepicker('update');
like image 844
Tornike Shavishvili Avatar asked Jan 22 '16 14:01

Tornike Shavishvili


1 Answers

Im using bootstrap datepicker. below code worked for me:

$('#my-datepicker').datepicker('setDate', 'now');
like image 181
Ramanujam Allam Avatar answered Oct 11 '22 18:10

Ramanujam Allam