To use the startOfQuarter
function from the date-fns
library, you first need to install the library and import the function into your Typescript file.
index.ts43 chars2 lines
The startOfQuarter
function takes a date as its argument and returns the start of the quarter that the date belongs to.
Here is an example usage of the function:
index.ts224 chars4 lines
In the above example, we create a Date
object for July 22, 2022 and pass it as an argument to the startOfQuarter
function. The function returns the start of the third quarter of 2022, which is July 1, 2022.
Note that startOfQuarter
returns a new Date
object and does not modify the original date object.
gistlibby LogSnag