@pmun/utils / startOf
Function: startOf()
ts
function startOf(date, unit): Date;
获取日期的开始时间
Parameters
date
日期
unit
OpUnitType
单位,可以是 'year', 'month', 'week', 'day', 'hour', 'minute', 'second'
Returns
Date
单位开始时间的日期对象
Example
ts
startOf(new Date('2023-05-15 15:30:45'), 'day') // Date 对象: Mon May 15 2023 00:00:00
startOf('2023-05-15 15:30:45', 'month') // Date 对象: Mon May 01 2023 00:00:00
startOf('2023-05-15 15:30:45', 'hour') // Date 对象: Mon May 15 2023 15:00:00