Skip to content

Instantly share code, notes, and snippets.

@FelixLuciano
Last active February 23, 2022 08:47
Show Gist options
  • Save FelixLuciano/fde2637bda77765231ca008750912250 to your computer and use it in GitHub Desktop.
Save FelixLuciano/fde2637bda77765231ca008750912250 to your computer and use it in GitHub Desktop.
Get my age
let me = {
birthday: new Date("2000-12-16T19:53:00-02:00"), // YYYY-MM-DDTHH:mm-GMT
get age () {
const livedTimeInMs = Date.now() - this.birthday.getTime()
const ageDate = new Date(livedTimeInMs)
const livedYears = ageDate.getUTCFullYear() - 1970
return livedYears
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment