Convert Minutes into Formatted Time String
Convert Minutes into Formatted Time String — Chronos Documentation.
convertMinutesToTime
Converts a number of minutes into a standardized "HH:MM" time string format.
Aliases
convertMinutesToHourMinutesgetTimeFromMinutesgetHourMinutesFromMinutes
Function Signature
convertMinutesToTime(minutes: Numeric): HourMinutes;Parameters
minutes:- Type:
Numeric(number or numeric string) - The total minutes to convert (e.g.,
90,"-45","120")
- Type:
Return Value
HourMinutes- A string inhour:minuteformat where:- Hour portion has 1+ digits (e.g.,
"1:05","12:30","123:45"etc.) - Minute portion always has 2 digits (e.g.,
"0:05","8:00")
- Hour portion has 1+ digits (e.g.,
Example Usage
playground.ts
Behavior
- Always returns absolute value (ignores negative signs)
- Formats minutes with leading zero (e.g.,
5→"0:05") - Handles both numbers and numeric strings
- Returns 24+ hour formats for large inputs (e.g.,
1500→"25:00")
Type Safety
Uses strict type definitions:
type HourMinutes = `${number}:${'00'|'01'|...|'59'}`;
type Numeric = number | `${number}`;Edge Cases
| Input | Output | Notes |
|---|---|---|
0 | "0:00" | Zero minutes |
"59" | "0:59" | String input |
-1600 | "26:40" | Ignores negative |
NaN | "NaN:NaN" | Invalid number handling |
Tip
For 24-hour formatted output with leading zeros create custom function:
playground.ts
Last updated: Fri, May 22, 2026 07:46:19AM (Coordinated Universal Time)
