how to calculate the age based on the birth date in this format 6/24/1976 mon/date/year...
A simple to use swift extension to get the age/how old is a NSDate
extension NSDate {
var age: Int {
let calendar: NSCalendar = NSCalendar.currentCalendar()
let now = calendar.startOfDayForDate(NSDate())
let birthdate = calendar.startOfDayForDate(self)
let components = calendar.components(.Year, fromDate: birthdate, toDate: now, options: [])
return components.year
}
}
Exemple:
NSDate(timeIntervalSince1970:0).age // => 45 (as of nov 2015) Epoch happened 45 year ago !
By the way, you should be careful, this is the western conception of age, the counting is different in some other countries (Korea for exemple).