To use the previousFriday function from the date-fns library in TypeScript, first, make sure you have the date-fns library installed in your project:
21 chars2 lines
Then, you can use the previousFriday function in your TypeScript code like this:
index.ts209 chars8 lines
In this example, we imported the previousFriday function from the date-fns library and used it to get the date object of the previous Friday from today's date. You can pass any valid date object as an argument to previousFriday function to get the date object of the previous Friday from that date.
Note that you can also use the previousFriday function with a specific date or a string:
index.ts280 chars7 lines
This code will output the date object of the previous Friday from September 20th, 2022 in the console.
gistlibby LogSnag