Get the value of bootstrap Datetimepicker in JavaScript

前端 未结 8 2007
心在旅途
心在旅途 2020-11-30 05:49

I need to get the value of Datetimepicker in my JavaScript function. I have made something like this, but it doesn\'t work:

$(\"#date\").click( function(){
         


        
8条回答
  •  臣服心动
    2020-11-30 06:31

    Since the return value has changed, $("#datetimepicker1").data("DateTimePicker").date() actually returns a moment object as Alexandre Bourlier stated:

    It seems the doc evolved.

    One should now use : $("#datetimepicker1").data("DateTimePicker").date().

    NB : Doing so return a Moment object, not a Date object

    Therefore, we must use .toDate() to change this statement to a date as such:

    $("#datetimepicker1").data("DateTimePicker").date().toDate();

提交回复
热议问题