Parse 12-hour or 24-hour clock strings, pass hour and minute numbers, or convert an existing value with time(). Instances are immutable, so every method that changes a value returns a new one.
create.js
import { time } from 'native-dates';const morning = time('9:30am');const evening = time('17:30');const alarm = time(6, 45);
Read the local time of day off any DateTime through its time property:
import { datetime, now } from 'native-dates';const standup = datetime('2026-11-16T09:30', 'America/Los_Angeles');standup.time.toString(); // '09:30:00'const currentClock = now().time;
Properties
Properties read the 24-hour clock fields from hours down to nanoseconds.
Property
Type
Description
text
string
Locale-formatted time of day, such as '9:30 AM'.
hour, minute, second
number
24-hour clock fields (0–23, 0–59, 0–59).
millisecond, microsecond, nanosecond
number
Sub-second clock fields (0–999).
Combining and fields
Place a time of day onto a calendar date, or replace individual clock fields.
on()
t.on(date, zone?): DateTime
Combines this time of day with a calendar date in a time zone and returns a DateTime. Mirrors calling at() on a CalendarDate.
Parameters
dateCalendarDateInputrequired
ISO date string, CalendarDate, DateTime, fields object, or Date.
zoneZone
IANA time zone name, fixed UTC offset, or 'UTC'. Defaults to the configured zone.
Add or subtract clock units, snap to unit boundaries, or round to a step increment. Calendar units such as days and weeks throw a RangeError because a time of day has no date.
Wrapping around midnight
Clock arithmetic wraps around the 24-hour day like a clock face, so adding 2 hours to 23:00 returns 01:00. Combine the time with a date using on() first when crossing midnight should advance the calendar day.
plus()
t.plus(amount, unit?): Timet.add(amount, unit?): Time
Moves forward on the 24-hour clock and returns a new Time, wrapping past midnight when needed. Also aliased as add().
Parameters
amountDurationInputrequired
Count paired with unit, Duration instance, duration string, fields object, or milliseconds.
unitUnit
Clock unit name when amount is a number, such as 'hours' or 'minutes'.
t.minus(amount, unit?): Timet.subtract(amount, unit?): Timet.remove(amount, unit?): Time
Moves backward on the 24-hour clock, wrapping before midnight when needed. Accepts the same inputs as plus(), and is also aliased as subtract() and remove().
Parameters
amountDurationInputrequired
Count paired with unit, Duration instance, duration string, fields object, or milliseconds.
Comparisons order times within a single day from midnight through the end of the day. Relational operators like < throw a RangeError, so compare values with methods or compare().
equals()
t.equals(other): boolean
Returns true when both values represent the exact same time of day.
Parameters
otherTimeInputrequired
Another Time or any input accepted by time().
Returns
boolean
true if both values match to the nanosecond.
time('5:30pm').equals('17:30'); // true
isBefore()
t.isBefore(other): boolean
Returns true if this time is earlier in the day than the other.
time('9:00am').isBefore('5:00pm'); // true
isAfter()
t.isAfter(other): boolean
Returns true if this time is later in the day than the other.
time('5:00pm').isAfter('9:00am'); // true
isSame()
t.isSame(other, unit?): boolean
Checks whether another time falls within the same clock unit, such as the same hour or minute. Calling isSame() without a unit checks exact equality.
Parameters
otherTimeInputrequired
Time to compare against.
unitUnit
Clock unit to compare, such as 'hour' or 'minute'.
t.until(other): Durationt.until(other, unit): number
Measures the signed time from this time to another within the same day, returning a negative span when the target is earlier. Pass a unit name to get the total length as a number.
Parameters
otherTimeInputrequired
Target time to measure toward.
unitUnit
Clock unit to return the total length in as a floating-point number.
Returns
Duration | number
A Duration balanced up to hours, or a number when unit is given.
t.since(other): Durationt.since(other, unit): number
Measures the time elapsed since an earlier time on the same day. Pass a unit name to get the total as a number.
time('5:00pm').since('9:00am', 'hours'); // 8
Formatting and conversion
format()
t.format(spec?, locale?): string
Formats the time of day using Intl.DateTimeFormat. Accepts a preset style, an options object, or a token pattern when @native-dates/plugins/tokens is loaded.
Parameters
specFormatSpecdefault 'short'
Time preset from 'short' through 'full', Intl.DateTimeFormatOptions object, or token pattern.
localestring
BCP 47 locale tag overriding the configured default for this call.
Returns the 24-hour ISO 8601 time string, printing sub-second digits in groups of three only when nonzero. toJSON() returns the same string for JSON.stringify().
Returns
string
ISO 8601 time string, such as '17:30:00' or '17:30:15.250'.