Get the value of bootstrap Datetimepicker in JavaS

2019-01-08 21:38发布

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(){
    alert(document.getElementById('datetimepicker1').value);
});

It gives me 'undefined'

8条回答
放我归山
2楼-- · 2019-01-08 22:34

Try this (worked for me), when i had boostrap inline date time picker this is a way how i get selected datetime.

var selected_datetime = $("#datetimepicker").data("date");
查看更多
Emotional °昔
3楼-- · 2019-01-08 22:39

I tried all the above methods and I did not get the value properly in the same format, then I found this.

$("#datetimepicker1").find("input")[1].value;

The above code will return the value in the same format as in the datetime picker.

This may help you guys in the future.

Hope this was helpful..

查看更多
登录 后发表回答