I’m curious if there’s a “best practices” approach to doing age verification. I was thinking I would grab the milliseconds from right now and the milliseconds from their birthdate and then see if their birthdate + ageReq * (365 * millPerYear) > currentMillisecond.
I believe this will work, but am wondering if there’s either anything faulty with this approach and/or if there’s a library that tackles whatever pitfalls I may not be anticipating here (for example, is there a leap year problem?)
This problem is language agnostic, I’m currently in Java, but am curious what the right way to do this would be irrespective of language.
TIA
You can try joda-time. And yes there is slight flaw in your check. This is not very accurate. Depending upon, how much legal compliance you have to follow, you can either live with it or not. Joda time is a good library as it does take care of all basic checks.
If you are looking for language agnostic. Then you can look into the code of Joda-time. as it precisely calculates the dates.