Skip to content

Instantly share code, notes, and snippets.

View jos3ph1205's full-sized avatar
🔥
Advancing frontend

Joseph1205 jos3ph1205

🔥
Advancing frontend
View GitHub Profile
@au5ton
au5ton / Age.js
Last active March 6, 2024 09:00
Age in decimals
//You can also use this to asses the age of anything, really.
//For example, dynamically display how long your company has been around, when your next appointment is, etc.
var birthday = new Date(1998,10,22); //Change to your birthday (year,month,day)
//Your age in decimals, with complete precision (1000 milliseconds, 60 seconds, 60 minutes, 24 hours, 365 days)
var age = ((new Date() - birthday) / 1000 / 60 / 60 / 24 / 365);
var precision = 1000; //However many zeros is how many places (1000 returns 3 places, 1 returns 0 places)
//With `precision` set to 1000, you would get something like 16.495, and 1 would just be 16