How to get the selected date value while using Bootstrap Datepicker? How to get the selected date value while using Bootstrap Datepicker? ruby-on-rails ruby-on-rails

How to get the selected date value while using Bootstrap Datepicker?


For bootstrap datepicker you can use:

$("#inputWithDatePicer").data('datepicker').getFormattedDate('yyyy-mm-dd');


You can try this

$('#startdate').val()

or

$('#startdate').data('date')


Bootstrap datepicker (the first result from bootstrap datepickcer search) has a method to get the selected date.
https://bootstrap-datepicker.readthedocs.io/en/latest/methods.html#getdate

getDate: Returns a localized date object representing the internal date object of the first datepicker in the selection. For multidate pickers, returns the latest date selected.

$('.datepicker').datepicker("getDate")

or

$('.datepicker').datepicker("getDate").valueOf()