Skip to content

Function: startOf()

ts
function startOf(date, unit): Date;

Set the start of a calendar unit (local time). Week starts on Monday. 将日期对齐到某个日历单位的开始(本地时间)。一周从周一开始。

Parameters

ParameterType
dateDate
unitStartEndUnit

Returns

Date

Example

ts
startOf(new Date('2026-05-08T15:30:00'), 'day') // 当天 00:00:00.000
startOf(new Date('2026-05-08T15:30:00'), 'month') // 2026-05-01 00:00:00.000

Since

1.0.0

Released under the MIT License.