I am using this code to get the date from the bootstrap-datepicker. I found several question swith the same issue and none of them seem to work for me. I am not sure what I am missing.
<div id="dateCal"></div>
This is my jQuery
$input = $("#dateCal");
$input.datepicker({
format: 'dd-mm-yyyy'
})
.on('changeDate', function(e){
console.log(e.date);
});
and mu console output looks like this:
Sat Jun 21 2014 00:00:00 GMT-0400 (EDT)
What am I doing wrong? I need e.date to come out as the format option is set.
When processing events in javascript (and jQuery or bootstrap), the "e" passed to the function is the event object . Reading e.date
could refer to the datetime of the event. You want to be reading this.value
, where this refers to the HTML element associated with the event, or in this case, your date field.
Do instead:
console.log(this.value);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.