Skip to content

Class: UtilsDate ​

Date and duration utilities: converting durations into readable formats.

Remarks ​

Available everywhere via k.Utils.Date. All methods are static.

Example ​

ts
const duree = k.Utils.Date.millisecondsToHms(3_661_000); // "1h1m1s"

Constructors ​

Constructor ​

ts
new UtilsDate(): UtilsDate;

Returns ​

UtilsDate

Methods ​

millisecondsToHms() ​

ts
static millisecondsToHms(n): `${number}h${number}m${number}s`;

Converts a duration in milliseconds into a hours h minutes m seconds s string.

Parameters ​

n ​

number

Duration in milliseconds.

Returns ​

`${number}h${number}m${number}s`

The formatted duration, e.g. "1h30m15s".

Example ​

ts
k.Utils.Date.millisecondsToHms(90_000); // "0h1m30s"