startOfYear

Commons
stable

Return a new Date set to January 1st of the same year at midnight. The original date is not mutated.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

date
required
Date
The reference date. Only the year is preserved; month is 0 (January), day is 1, time is 00:00:00.

API

Return value

The value returned by this util.

A new Date at 2024-01-01T00:00:00 (or the equivalent year).

Usage

Examples

Ready-to-paste usage snippets.

Get the first day of the year

typescript