JQuery bootstrap-datetimepicker change event

I am using the bootstrap-datetimepicker plugin from Jonathan Peterson in my project.

I had a problem with the change event :

If I define the event as follows:

$('#Release').on('dp.change', function(e){ console.log(e.date()); }) 

I get an error message:

Uncaught TypeError: e.date is not a function

Does anyone know how to get a new date value in a change event?

+4
source share
3 answers

Looking at this link seems like you are very close. You need to remove the brackets in order to get the correct value. As you are currently trying to register a value, the browser believes that it needs to call the function.

 $('#Release').on('dp.change', function(e){ console.log(e.date); }) 
+19
source

Thanks to Kenneth's suggestion, I realized:

 $('#Release').on('dp.change', function(e){ var formatedValue = e.date.format(e.date._f); console.log(formatedValue); }) 

Thanks Kenneth :)

+2
source

Please use this code to get the datetimepicker change event:

  $('.datepicker').datetimepicker( { format: 'MM/DD/YYYY' }).on('dp.change', function (e) { }); 
+1
source

All Articles