Get age from date of birth – Javascript
Suppose you are given a date of birth of any user and you have to get his age from it. You can do it in Javascript using the following code:
const date = new Date("1993-07-27")
const current_date = new Date()
let age = current_date.getTime() - date.getTime()
// 948161820692
age = new Date(age)
// 2000-01-18T02:17:18.105Z
age = age.getFullYear()
// 2000
age = age - 1970
// 30