Linked Questions

Popular Questions

How to get the total minutes from 2 fields

Asked by At

I want to get the total minutes in the result, sample

field 1 14:30
field 2 14:45
result 00:15

Example

I'm using the following code, however, I only want to get 24 hours. 14:46:22 GMT-0800 (Pacific Standard Time) NO GOOD 14:46:22 I WANT THIS RESULT and also the total in hte

$(
  function() {
    let lastFocusEl = null;

    $('#time').click(function() {
      var time = new Date();
      if (lastFocusEl) lastFocusEl.value = time.toTimeString();
    });

    let f = function() {
      lastFocusEl = this
    };
    $('#time-holder').focus(f);
    $('#time-holder2').focus(f);

  }
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<input type="text" value="" id="time-holder">
<input type="text" value="" id="time-holder2">
<input type="text" value="" id="result">

<input type="button" value="time" name="timer" id="time">

Related Questions