You can use the previousDay
function from the date-fns library in JavaScript to get the date of the previous day. Here's how to use it:
First, install the date-fns library via npm:
21 chars2 lines
Then, import the previousDay
function and use it to get the date of the previous day:
index.tsx208 chars7 lines
You can also pass a second argument to the previousDay
function to specify the number of days to go back:
index.tsx153 chars5 lines
gistlibby LogSnag