Return the end of a week for the given date.
Return the end of a week for the given date. The result will be in the local timezone.
// CommonJS
var endOfWeek = require('date-fns/endOfWeek')
// ES 2015 import endOfWeek from 'date-fns/endOfWeek'
// ESM
import { endOfWeek } from 'date-fns'
endOfWeek(date, [options])
| Name | Description |
|---|---|
date |
the original date |
options |
an object with options. |
options.locale |
the locale object. See [Locale]{@link https://date-fns.org/docs/Locale} |
options.weekStartsOn |
the index of the first day of the week (0 - Sunday) |
| Description |
|---|
|
the end of a week |
| Type | Description |
|---|---|
TypeError |
1 argument required |
RangeError |
|
// The end of a week for 2 September 2014 11:55:00: const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0)) //=> Sat Sep 06 2014 23:59:59.999
// If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
//=> Sun Sep 07 2014 23:59:59.999
© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/endOfWeek