Shane O'Seasnain Shane O'Seasnain - 1 year ago 92
iOS Question

how to get today's date less 18 years

What is the correct way to get date of 18 years ago from today's Date in Swift3?

In Swift2, I had

let startingDate = NSDate(timeIntervalSinceNow: -600000000)

Answer Source

If you want date with 18 year less you can use Calendar unit year for that.

let date = .year, value: -18, to: Date())


enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download