Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 991
Shane O'Seasnain Avatar asked Sep 27 '16 06:09

Shane O'Seasnain


People also ask

How do I subtract a date from a previous date in Excel?

What'll you need to do is subtract today's date from the project start date. Excel has a TODAY function built in, which will save you from typing in the date in the correct format and continually updating as the days change. So, the formula is: =TODAY() – B2.

How do I format the dates older than today?

For formatting the dates older than today, please copy and paste the formula =$A2<TODAY () into the Format values where this formula is true box; 3). Click the Format button.

How to calculate years from today in Excel?

Another easy way to calculate years from today is to use a simple subtraction formula. Type the formula in an empty cell, Here, the formula finds the difference between the dates provided in cells E6 and C6. We are dividing the result by 365 to find the difference in year.

What is the age limit for date validation in Android?

Date validation to be less than 18 years from current date in android Ask Question Asked7 years, 8 months ago Active4 years, 2 months ago Viewed9k times 2

How to conditional format dates less than/greater than today in Excel?

How to conditional format dates less than/greater than today in Excel? 1. Select the range A2:A15, then click Conditional Formatting > Manage Rules under Home tab. See screenshot: 2. In the Conditional Formatting Rules Manager dialog box, click the New Rule button. 3. In the New Formatting Rule ...


1 Answers

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

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

Output

enter image description here

like image 196
Nirav D Avatar answered Oct 03 '22 18:10

Nirav D