Incorrectly considers birthday. t, e if today is February 26, 2019, and others are somewhere on 10.10.2019., then it shows 25 years.
if(userInfo && userInfo.birthDay){ let date = new Date(HexToSignedInt(userInfo.birthDay)); let optionsTime = { year: 'numeric', month: '2-digit', day: '2-digit' }; birthDay = date.toLocaleString('en-GB', optionsTime).replace(',', ' '); // years = this.calculateAge(date.getFullYear(), date.getUTCMonth() + 1, date.getUTCDate()); years = this.calculateAge(date.getFullYear(), date.getMonth(), date.getDate()); } calculateAge(year, month, day) { let currentDate = new Date(); let currentYear = currentDate.getFullYear(); let currentMonth = currentDate.getMonth(); let currentDay = currentDate.getDate(); // You need to treat the cases where the year, month or day hasn't arrived yet. let age = currentYear - year; // if (currentMonth < month) { if (currentDate < month) { return age; } else { if (currentDay >= day) { return age; } else { age--; return age; } } }