clean-jsdoc-theme TypeDoc APIv0.0.0

startOf

startOf( date: Date, unit: 'year' | 'month' | 'week' | 'day', ): Date

Source: date.ts:282

Gets the start of a time period

Parameters

  • date (Date) — Input date
  • unit ("year" | "month" | "week" | "day") — Time unit

Returns

  • Date — Start of the period

Example

CODE
startOf(new Date('2024-03-15 14:30:00'), 'day')
// 2024-03-15 00:00:00

startOf(new Date('2024-03-15'), 'month')
// 2024-03-01 00:00:00