---
layout: post
title:  "JS Hack - Calculating Age"
date:   2016-01-05 08:01:05
categories: feature
tags: featured
image: /assets/article_images/jslogo.png
---

JS Hack - Calculating Age
----------------  
In this post I will share an extremely useful hack to apply in JavaScript.
If you ever need to create a function that calculates age based on a date of birth, I recommend that you use this function that makes an extremely performative spell:

- function calculating age
> function calcAge(dateString) {
>   var birthday = +new Date(dateString);
>   return ~~((Date.now() - birthday) / (31557600000));
> }




---
layout: post
title:  "JS Hack - Calculating Age"
date:   2016-01-05 08:01:05
categories: feature
tags: featured
image: /assets/article_images/jslogo.png
---

JS Hack - Calculating Age
----------------  
In this post I will share an extremely useful hack to apply in JavaScript.
If you ever need to create a function that calculates age based on a date of birth, I recommend that you use this function that makes an extremely performative spell:

```javascript

function howOld(dateString) {
  var bday = +new Date(dateString);
  return ~~((Date.now() - bday) / (31557600000));
}

howOld('06/11/1990'); //26

```

Update post - js hack 1
Update post - js hack 1

Update post - js hack 1