I'm playing with swift. I want to show how many years/months/days has been passed since the specific date(NSdate).
If the specific date is 08/01/2016 and current date is 08/11/2016, it will show only "10day(s) has been passed". If the specific date is 08/11/2015, it will show "1year(s) 0 month(s) 0day(s)has been passed"
Do something like this. Use your dates in
let date1 = NSDate() let date2 = NSDate() let form = NSDateComponentsFormatter() form.maximumUnitCount = 2 form.unitsStyle = .Full form.allowedUnits = [.Year, .Month, .Day] let s = form.stringFromDate(date1, toDate: date2)