New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to get a person's age #627
Comments
You can use something like |
Ok it's working. Thanks a lot. |
const age = moment().diff(birthday, 'years');
const isLegal = (age >= 18); |
|
this works but it gives a warning on console, any idea why?
|
@josebedoya That wouldn't be necessary if you just swapped the relative calculations like @eballeste did: moment().diff(birthdate, 'years') |
It still doesn't work correctly if the person has recently (less than a month ago) had their birthday. |
|
By adding the optional third parameter, you can receive a float back which will be less than 18 if you try: |
Hi, this is more a question then an issue but here it go.
I want to use moment to check if a person is more then 18 years old. What is the best way to do this? Since if i use the .fromNow() function i will get 18 years if the person has more then 17 and a half.
The text was updated successfully, but these errors were encountered: