Age calculator in iOS swift
Solution:
let gregorian = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian)!
let age = gregorian.components([.year], from: datePicker.date, to: currentDate as Date, options: [])
print(age.year)
You can print the age based on the date picked in date picker using the above method.
Comments
Post a Comment