我想知道如何計算登錄時間和登出時間之間的差異,例如:登錄時間:上午8:00和登出時間:下午5:00,而我應該在總時間內得到9小時。iOS Swift - 計算兩次之差
這是被保存到火力
// Set the time
let timeFormatter = DateFormatter()
timeFormatter.dateStyle = .none
timeFormatter.timeStyle = .short
timeFormatter.amSymbol = "AM"
timeFormatter.pmSymbol = "PM"
let timeString = timeFormatter.string(from: date)
可能的重複[使用swift 3和xcode 8在兩週內和兩天之間的差異](https://stackoverflow.com/questions/42294864/difference-between-2-dates-in-weeks-and-days -using-swift-3-and-xcode-8) – aksh1t
重複的https://stackoverflow.com/a/42017851/2303865 –
@LeoDabus,對不起。感謝提醒。祝你有美好的一天! – TSM