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

Calculates the number of full years between two dates. The order of the arguments does not matter. The date must be equal or past for it to count as a full year.

Examples

Example 1

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

Parameters

start: Date
end: Date

Return Type

number

Usage

import { yearsBetween } from ".";