How to calculate age from date of birth in React js?
Solution To calculate age from date of birth in React, you can use moment library diff() method. You have to use just like it currentDate.diff(dobDate, 'years') and it will return differance year between currentDate and dobDate. Snippet In this snippet, we will create take current date and date of birth date. Apply moment library diff() method with years parameter to get differance year. // Get the current date let currentDate = moment(new Date()); // Get date of birth date let dobDate = moment(new Date('1999-12-31')); // get no of year let year = currentDate....