Skip to main content

getAge

Calculates the current age based on a given birth date.


Code

🔗 View source code


Interface

typescript
function getAge(birthDate: string | number | Date): number

Usage

typescript
import { getAge } from '@modern-kit/utils';

// When the current date is January 1, 2025
getAge(new Date('2006-01-01')); // 19

// String format is also accepted.
getAge('2006-01-01'); // 19