Daniels Jirgensons Daniels Jirgensons - 1 year ago 81
jQuery Question

Load date to input field after selecting from Bootstrap datetimepicker

What I am trying to do is, after selecting a date on Bootstrap Datetimepicker, it should load a value on my input field, but I don't know how to do that. There's my JSFiddle.

This is my jQuery for datetimepicker

$(function () {
$('.datetimepickerinline').datetimepicker({inline: true});

I need to use it for all inputs, or in other words, closest input field.

Answer Source

Here is solution you want: jsfiddle

$('.datetimepickerinline').on('change dp.change', function(e){

See reference here

Further more, I noticed that you want use moment.js

You can use something like this, using custom format:

$('.datetimepickerinline').on('change dp.change', function(e){
   $('input').val(moment($(this).data('date')).format('DD/MM/YYYY, h:mm'));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download