To use the startOfYear
function from the date-fns
library in TypeScript, you'll need to import it like this:
index.ts40 chars2 lines
Then, you can use the function to get the start of the year for a given Date
object like this:
index.ts109 chars3 lines
Note that the startOfYear
function returns a new Date
object representing the start of the year, and does not modify the original Date
object. By default, the function sets the time component of the new object to 00:00:00.000
.
gistlibby LogSnag