You can use the isYesterday function from the date-fns library in TypeScript by importing it and passing in a Date object.
Here's an example:
index.ts175 chars10 lines
In the example above, we import the isYesterday function from the date-fns library. We then create a Date object for the date 2021-07-20. We pass this Date object to the isYesterday function which returns a boolean indicating whether the date was yesterday.
We then check the boolean value and log Yesterday if the date was yesterday or Not yesterday if it wasn't.
gistlibby LogSnag