Saltar al contenido principal

Function: useDiff()

useDiff(start, end): string

Defined in: src/core/services/dates.service.ts:28

Returns a human-readable diff between two dates as years, months, and days.

Parameters

start

string | PlainDate

Start date (ISO string or PlainDate).

end

string | PlainDate

End date (ISO string or PlainDate).

Returns

string

A formatted string, e.g. "2 years, 3 months and 15 days".

Example

useDiff("2020-01-01", "2022-04-16");
// "2 years, 3 months and 15 days"