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'.
Moves forward to the start of the clock unit after the one containing this time, wrapping around midnight. Always advances into the next unit, so calling startOfNext('hour') on 14:00:00 returns 15:00:00.
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.
Creates a half-open TimeRange from this time until the target time or elapsed duration. An end earlier than the start wraps overnight across midnight. Use for() to pass an explicit duration length (refusing endpoints and unitless numbers).
Parameters
endTimeInput | DurationInput | numberrequired
Closing time, clock duration, or numeric count paired with unit.
unitUnit
Clock unit name when the first argument is a numeric count, such as 'hours' or 'minutes'.
Formats the time of day using built-in presets, custom names from configure(), options objects, or token patterns.
Localized 'LT' and 'LTS' presets are built in, and options objects ignore date and zone keys automatically. See Formatting for the full preset and token reference.
Parameters
specFormatSpecdefault 'short'
Built-in or configured format name, Intl options object, or token pattern.
localestring
BCP 47 locale tag overriding this time's or the configured locale for one call.
Reads the locale carried on this time, or returns a copy formatted in another locale across text previews, presets, and every value derived from it. Passing an empty tag clears the carried locale, and lang() works as an alias.
Parameters
tagLocale | null | undefined
BCP 47 locale tag to carry forward, or null to clear an existing tag.
Returns
Time | Locale | undefined
The active tag when called with no arguments, or a new Time carrying tag.
Shorthand alias for locale() that reads or attaches a BCP 47 locale tag on this time.
toString()
t.toString(): stringt.toJSON(): string
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'.