function yearsBetween
yearsBetween(
start: Date,
end: Date,
): number

Calculates the years between two dates. The date must be equal or past for it to count as a full year.

Examples

Example 1

yearsBetween(new Date('2007-08-01', '2008-07-31')); // 0
yearsBetween(new Date('2007-08-01', '2008-08-01')); // 1

Parameters

start: Date
end: Date

Return Type

number

Usage

import { yearsBetween } from ".";