Skip to content

Function: endOf()

ts
function endOf(date, unit): Date;

Set the end of a calendar unit (local time). Week ends on Sunday 23:59:59.999. 将日期对齐到某个日历单位的结束(本地时间)。一周结束于周日 23:59:59.999。

Parameters

ParameterType
dateDate
unitStartEndUnit

Returns

Date

Example

ts
endOf(new Date('2026-05-08T10:00:00'), 'month') // 2026-05-31 23:59:59.999

Since

1.0.0

Released under the MIT License.