Here's an example of how you can use the isSameQuarter
function from the date-fns
library in TypeScript:
index.ts194 chars9 lines
In this example, we first import the isSameQuarter
function from the date-fns
library.
Then, we create two date objects: date1
and date2
.
Finally, we call the isSameQuarter
function with the two dates as arguments. The function returns a boolean value indicating whether the two dates are in the same quarter of the year.
We store the result in the result
variable and log it to the console, which should print true
since date1
and date2
are in the same quarter of the year (Q1 2021).
gistlibby LogSnag