calculate-age
This package is use to calculate age of a given date of birth.
Installation
npm install calculate-age
Using
Function Parameter
calculateAge(dateOfBirth: string | Date, compareDate?: string | Date)
Example
import calculateAge from 'calculate-age'
const output = calculateAge('1988-10-26', '2021-01-26').getObject()
const output = calculateAge('1988-10-26', '2021-01-26').getString()
Output
getObject() --> getString()
Release Notes - Version 1.0.0
Features
- Added TypeScript support to the package.
- Changed from class-based to function-based implementation for
calculateAge
method, removing the need for new
keyword. - Made
compareDate
optional in calculateAge
method, defaulting it to today's date.
Contributing
If you find a bug or willing to add some enhancement, pull requests are very welcome
:copyright: License
MIT