mddanishyusuf / dailyhack

🐱‍💻 Tiny Tiny Hacks we use in our daily life.
https://dailyhack.now.sh/
149 stars 15 forks source link

Javascript calculate age from date small function #41

Open carlosbranco opened 5 years ago

carlosbranco commented 5 years ago
function calcAge(dateString) {
  var birthday = +new Date(dateString);
  return ~~((Date.now() - birthday) / (31557600000));
}
mddanishyusuf commented 5 years ago

HaHa. It's funny. I'll set this function to my CRON job that will tell me every 6 hour my age :)