Skip to content

round ​

Rounds a TheDate or SerializedTheDate to the specified unit (unit).

Interactive example ​

Syntax ​

typescript
function round(
	input: TheDate | SerializedTheDate,
	unit?: RoundUnit
): TheDate

RoundUnit corresponds to Unit without the millisecond option (day, week, month, year, etc.).

Parameters ​

  • input: Date to round (TheDate or SerializedTheDate).
  • unit: Target unit (day by default).

Return value ​

A TheDate rounded to the requested unit.

See also ​

Released under the MIT license.