Check out example codes for "get hours difference between two dates swift". It will help you in understanding the concepts better.
Code Example 1
let cal = Calendar.current
let components = cal.dateComponents([.hour], from: date2, to: date1)
let diff = components.hour!
Learn ReactJs, React Native from akashmittal.com