You can use the lastDayOfISOWeek
function from the date-fns
library in JavaScript to get the last day of the ISO week (which starts on Monday).
Here's an example code snippet that shows how to use the function:
index.tsx210 chars7 lines
In the example above, the lastDayOfISOWeek
function is imported from the date-fns
library. Then, a Date
object is created for a Tuesday in September 2021.
The lastDayOfISOWeek
function is then called with the date
object, which returns the Date
object for the last day of the ISO week (Sunday).
Finally, the result is logged to the console.
Note that the lastDayOfISOWeek
function returns a Date
object, so you can use the usual Date
methods to format or manipulate the result as needed.
gistlibby LogSnag