Finding the date 18 years ago
Why don't you use the setFullYear() method?

eighteenYearsAgo = eighteenYearsAgo.setFullYear(eighteenYearsAgo.getFullYear()-18);


Instead of using the yyymmdd() function, you can also use the Date.toISOString() method. This will also show the time... but you can get rid of it in several ways (split on "T" or use a regular expression).