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

前端 未结 12 951
有刺的猬
有刺的猬 2020-11-28 10:37

Using jquery and the Bootstrap Datepicker, how do I get the new date value I selected using the Bootstrap Datepicker? FYI, I\'m using Rails 3 and Coffescript.

I set

12条回答
  •  独厮守ぢ
    2020-11-28 10:43

    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() 
    

提交回复
热议问题