Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery bootstrap-datetimepicker change event

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

I'm having a problem with change event :

If I define event like this :

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

I get the error :

Uncaught TypeError: e.date is not a function

Anyone knows how to get new date value on change event ?

like image 793
user5198552 Avatar asked Aug 06 '15 14:08

user5198552


3 Answers

Looking at that link, it appears you are very close. You need to remove the parenthesis to get the right value.The way you currently are trying to log the value makes the browser think it needs to call a function.

$('#Release').on('dp.change', function(e){ console.log(e.date); })
like image 76
Kenneth Salomon Avatar answered Oct 08 '22 15:10

Kenneth Salomon


Please use this code to get change event of datetimepicker:

 $('.datepicker').datetimepicker(
    { format: 'MM/DD/YYYY' }).on('dp.change', function (e) {  });
like image 16
Mohammed Jikriya Avatar answered Oct 08 '22 14:10

Mohammed Jikriya


Thanks to Kenneth suggestion, I figured out :

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

Thank you Kenneth :)

like image 13
user5198552 Avatar answered Oct 08 '22 13:10

user5198552