Get time difference between two times in swift 3 : <p>I have 2 variables where I get 2 times from datePicker and I need to save on a variable the difference between them.</p>

<pre><code>    let timeFormatter = DateFormatter()
    timeFormatter.dateFormat = "HHmm"

    time2 = timeFormatter.date(from: timeFormatter.string(from: datePicker.date))!
</code></pre>

<p>I have tried to get the timeIntervalSince1970 from both of them and them substract them and get the difference on milliseconds which I will turn back to hours and minutes, but I get a very big number which doesn't corresponds to the actual time.</p>

<pre><code>let dateTest = time2.timeIntervalSince1970 - time1.timeIntervalSince1970
</code></pre>

<p>Then I have tried using time2.timeIntervalSince(date: time1), but again the result milliseconds are much much more than the actual time.</p>

<p>How I can get the correct time difference between 2 times and have the result as hours and minutes in format "0823" for 8 hours and 23 minutes?</p>
