Skip to content
Advertisement

Compare date with todays date 10 years ago

I want to check if the given date is higher than 10 years ago from today (so the person would have less than 10 years). I have searched many info with no possitive result.

EDIT: When I alert “objetoFechaNacimiento”, if the user entered “22/1/2015”, it alerts “Sat Oct 01 2016 00:00:00 GMT+0200”. This must be the problem…

This is what I got:

JavaScript

Advertisement

Answer

Just reformat the date to a valid format

Also when you create a minima date you can use setFullYear on that date instead of saving the result of a setDate

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement