Extract Time From UTC
Extract Time From UTC — Chronos Documentation.
extractTimeFromUTC
Extracts the time portion from a UTC offset string, converting it to ±HH:MM format.
Function Signature
extractTimeFromUTC(utc: UTCOffset): `-${Time}` | Time;Parameters
utc: A UTC offset string in format:UTC+HH:MM(positive offset)UTC-HH:MM(negative offset)
Returns
The time portion in ±HH:MM format:
HH:MMfor positive offsets (e.g.,"05:30")-HH:MMfor negative offsets (e.g.,"-04:00")
Example Usage
playground.ts
Notes
- Preserves the original sign (+/-)
- Returns only the time portion without "UTC" prefix
- Maintains leading zeros for single-digit hours/minutes
- Works with all valid
UTCOffsetformats
Aliases
extractTimeStringFromUTCgetTimeStringFromUTC
Type Definition
type UTCOffset = `UTC${'+00'|'+01'|...|'+14'|'-00'|'-01'|...|'-14'}:${'00'|'15'|'30'|'45'}`;
type ClockTime = `${ClockHour}:${ClockMinute}`;Use Cases
- Displaying timezone offsets without UTC prefix
- Preparing time data for further processing
- Formatting timezone information for UI display
- Timezone conversion utilities
Conclusion
The extractTimeFromUTC function provides:
- Clean extraction of time portion from UTC strings
- Consistent formatting in
±HH:MMformat - Simple integration with time-related operations
- Type-safe input/output handling
Last updated: Fri, May 22, 2026 07:46:19AM (Coordinated Universal Time)
