Avatar
@swift-4.1.3 import Foundation let d1 = Date() let d2 = Date() + 12345 let diff = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute, .second, .nanosecond], from: d1, to: d2) print(String(format: "%02d:%02d:%02d.%d", diff.hour!, diff.minute!, diff.second!, diff.nanosecond!) )