Function: startOf()
ts
function startOf(date, unit): Date;Set the start of a calendar unit (local time). Week starts on Monday. 将日期对齐到某个日历单位的开始(本地时间)。一周从周一开始。
Parameters
| Parameter | Type |
|---|---|
date | Date |
unit | StartEndUnit |
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.000Since
1.0.0