To use the endOfDecade function from date-fns in Javascript, you first need to install the date-fns library using a package manager such as NPM or Yarn.
21 chars2 lines
Once date-fns is installed, you can import the endOfDecade function and use it in your code like this:
index.tsx225 chars7 lines
The endOfDecade function takes a date as an argument and returns a new Date object representing the last millisecond of the decade that the original date belongs to. In the example above, endOfDecadeDate will be a Date object representing December 31, 2019, which is the last day of the decade that includes the original date: July 12, 2019.
gistlibby LogSnag