@toolsnap/age-calculator
v1.0.0
Published
Lightweight age calculation utilities for Node.js and browsers.
Downloads
65
Maintainers
Readme
@toolsnap/age-calculator
Lightweight, zero-dependency age calculation utilities for Node.js and browsers.
Installation
npm install @toolsnap/age-calculatorUsage
const { calculate, inDays, inMonths, isMinor, nextBirthday } = require('@toolsnap/age-calculator');
calculate('1995-06-15', '2026-04-19');
// { years: 30, months: 10, days: 4 }
inDays('2000-01-01'); // total days lived
inMonths('2000-01-01'); // total months lived
isMinor('2015-01-01'); // true or false
nextBirthday('1995-06-15'); // next birthday Date objectAPI
| Function | Description |
|----------|-------------|
| calculate(birth, [to]) | Age as {years, months, days} |
| inDays(birth, [to]) | Total days from birth |
| inMonths(birth, [to]) | Total months from birth |
| isMinor(birth, [to]) | Whether the person is under 18 |
| nextBirthday(birth) | Next upcoming birthday |
Online Tool
Try our free online age calculator — no install needed.
License
MIT
