Skip to content Skip to sidebar Skip to footer

Bootstrap Datetimepicker Get Time

I am using Bootstrap datetimepicker in a form insider my Meteor.JS app in order to have two time picker elements. Below is the code I have so far which detect the onChange event fo

Solution 1:

I hope this helps some one.

HTML

<div name="startTime" class="input-group time">
   <input  class="form-control" type="text" value="" >
   <span class="input-group-addon"><i class="fa fa-clock-o"></i></span>
</div>

JS

  $('.time').datetimepicker({
      format: 'LT'
  }).on("dp.change",function(e){
      var date = e.date;//e.date is a moment object
      var target = $(e.target).attr('name');
      console.log(date.format("HH:mm:ss"))//get time by using format
  })

e.date is a moment object thus time can derived by using format("HH:mm:ss")


Post a Comment for "Bootstrap Datetimepicker Get Time"