lastDayOfWeek

Modified on Thu, 24 Aug 2023

Description

Use this function to obtain the last day of a week for the given date. The result will be in the local timezone.

Syntax

lastDayOfWeek(date, options)

Returns

Return ValueDescription
DateReturns a Date object representing the last day of the week for the given date in the local timezone.

Sample

ExampleResultDescription
lastDayOfWeek(2023-04-09, { weekStartsOn: 1 })2023-04-15Returns the last day of the week for April 9, 2023, in the local timezone. The option "weekStartsOn" is set to 1, meaning the week starts on Monday. Therefore, the function returns Saturday, April 15, 2023, as the last day of the week containing April 9, 2023.

To view all the Date functions, click here.

See Also