Assuming you've installed the date-fns
package, you can use the endOfDecade
function as follows:
index.ts188 chars7 lines
In the above code, we imported the endOfDecade
function from the date-fns
package, created a new Date object with a specific date, and passed it to the endOfDecade
function (which returns the end date of the decade that date falls in). Finally, we logged the output to the console.
Note that the date-fns
library supports many other useful functions for working with dates, so be sure to check its documentation for more information.
gistlibby LogSnag