I'm using jquery datetimepicker, I want to get the difference between start time and end time.
How can I calculate it using javascript/jquery code?
I set up the start and end time in html like.
<div class='input-group date' id='time_starts_at'>
<input class="form-control" placeholder="Time Start's At *" autocomplete="off" type="text" name="" id="calendar_starts_at_time">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
<div class='input-group date' id='time_ends_at'>
<input class="form-control" placeholder="Time End's At *" autocomplete="off" type="text" name="" id="calendar_ends_at_time">
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
And, my jquery codes by getting its value:
var timeFrom = $start_time.data('date');
var timeTo = $end_time.data('date');
Curently, I'm doing it manually by splitting the Hour and Minutes. Adding validation on it by checking the values before subtracting it.
Is there a best way to do it ?
Please help. Thank you.