To use the issameyear
function from date-fns
in TypeScript, first install date-fns
library using npm:
21 chars2 lines
Then, import the function and call it with two date values:
index.ts188 chars9 lines
The isSameYear
function returns a boolean indicating whether or not the year of the first date is the same as that of the second date.
You can also use import * as dateFns from 'date-fns';
to import the whole library with all of its functions and then call dateFns.isSameYear(date1, date2);
gistlibby LogSnag