I have a date1 and the current Date when the view did load. Now I want to display how many days have passed since the day.
let timeInterval = date1.timeIntervalSince(date2)
Now I want to convert the timeInterval in days. Anyone could help?
I have a date1 and the current Date when the view did load. Now I want to display how many days have passed since the day.
let timeInterval = date1.timeIntervalSince(date2)
Now I want to convert the timeInterval in days. Anyone could help?
Rather than using TimeInterval you can get the number of days directly by using the Calendar class and DateComponents
let days = Calendar.current.dateComponents([.day], from: date1, to: date2)
print(days.day!)