dpaulos6 / exact-date

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exact Age Calculator

This package calculates the exact age of a given date of birth.

Installing

npm install exact-age

or

pnpm install exact-age

or

yarn add exact-age

Example Usages

Common JS

const exactAge = require("exact-age");

// Using String format
// Assuming the current day as 03-20-2024
const dob = "03-20-2000";
const age = exactAge(dob); // Output: 24

// Using Date format
// Assuming the current day as 03-20-2024
const dob = new Date("06-22-2005");
const age = exactAge(dob); // Output: 19

ES6

import exactAge from "exact-age";

// Using String format
// Assuming the current day as 03-20-2024
const dob = "03-20-2000";
const age = exactAge(dob); // Output: 24

// Using Date format
// Assuming the current day as 03-20-2024
const dob = new Date("06-22-2005");
const age = exactAge(dob); // Output: 19

Socials

Instagram Instagram Instagram Instagram

License

This project is licensed under the MIT License.

About

License:MIT License


Languages

Language:TypeScript 100.0%