How to convert date of birth to age.
Example input from user, "Tue Aug 16 2016 11:13:59 GMT+0530 (India Standard Time)"
Based on the above, expected output is 6 days old.
Thanks
How to convert date of birth to age.
Example input from user, "Tue Aug 16 2016 11:13:59 GMT+0530 (India Standard Time)"
Based on the above, expected output is 6 days old.
Thanks
The following should be an easy way to do it. You might want to add checking to ensure it's not a future date.
moment("Tue Aug 16 2016 11:13:59 GMT+0530 (India Standard Time)").fromNow(true)
Check the charts from the Moment.js docs for fromNow to see what it will return for different ranges. You can use fromNow source code as template for custom code in order to format with different set of ranges.
Add library to meteor as per Moment.js docs
meteor add momentjs:moment