createTime
The createTime() function builds a TheTime from a millisecond value or from a structured time object. It also accepts an ISO time string via the value field.
Interactive example
Syntax
typescript
function createTime(
input: number & TimeConstraint,
unit: Units
): TheTime
function createTime<
GenericInput extends number | TheTime | SpoolingTime
>(
input: GenericInput
): MayBeTimeTimeConstraint ensures the strict (number, unit) overload only accepts literal values and that they stay within the supported bounds for each unit.
INFO
Use the strict overload for constants known in advance (tests, defaults). For dynamic values, prefer the overload that returns MayBeTime.
Parameters
input: A millisecond value, aTheTime, or aSpoolingTimeobject (week, day, hour, minute, second, millisecond, value).unit: Required unit for numeric input when using the strict overload ("millisecond","second","minute","hour","day","week").
Return value
TheTimewhen called with(number, unit)or with aTheTimeinput (returned as-is).MayBeTime(Either) when called with a number orSpoolingTime.
See also
create– Builds aTheDate.createTimeOrThrow– Throws instead of returningMayBeTime.toTimestamp– Extracts the timestamp from aTheDate.
