0

I'm doing {{today.getTime() - employee?.birthDate.getTime()}}, today being a Date instance with the date of today and employee?.birthDate being an instance of Date with the birthDate of the employee.

Thanks for your time :)

Pierrick Martellière
  • 1,554
  • 3
  • 21
  • 42
  • Possible duplicate of [Calculate age given the birth date in the format YYYYMMDD](https://stackoverflow.com/questions/4060004/calculate-age-given-the-birth-date-in-the-format-yyyymmdd) – Igor Jul 24 '18 at 21:27
  • Possible duplicate of [Get age from Birthdate](https://stackoverflow.com/questions/10008050/get-age-from-birthdate) – Igor Jul 24 '18 at 21:27
  • What have you tried, what's wrong with it and can you make a small repro? (stackblitz for ex) – maxime1992 Jul 24 '18 at 21:30
  • My bad, I was doing this with a null employee's birthDate, will upload my post tomorrow if I have some issues. The form I tried is `{{today.getTime() - employee?.birthDate.getTime()}}` – Pierrick Martellière Jul 24 '18 at 21:34
  • have you tried the [date pipeline](https://angular.io/api/common/DatePipe)? It has variety of options which you can use – imans77 Jul 24 '18 at 21:41
  • Yes I think I'll use it with the result of today.getTime() - birthdate.getTime() – Pierrick Martellière Jul 24 '18 at 21:52

0 Answers0