Skip to content

A simple function for calculate the age from a date.

License

Notifications You must be signed in to change notification settings

rich-97/calc-age-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calc-age-js

npm npm

Simple function for calculate the age of a person from a date. This package can calculate the age in years, months and days.

Installation

Via npm:

npm install calc-age

Usage

Simple example:

const calcAge = require('calc-age')
const date = { year: 1989, month: 3, day: 9 }
const myAge = calcAge(date)

console.log(myAge.years) // Should be equal to 28 (current year: 2017).

This function also accept an string as number, the following object is valid:

const date = { year: '1989', month: '3', day: '9' }

If you use an string as number, the string always should be only one or more digits.

About

A simple function for calculate the age from a date.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published