Skip to main content

Time

ฦฌ Time: Format["hh:mm:ss[.sss]"] & string

An Iso.Time represents a wall-clock time, with a precision in milliseconds, and without any time zone. "Wall-clock time" refers to the concept of a time as expressed in everyday usage โ€” the time that you read off the clock on the wall. For example, it could be used to represent an event that happens daily at a certain time, no matter what time zone.

Iso.Time refers to a time with no associated calendar date; if you need to refer to a specific time on a specific day, use Iso.DateTime. A Iso.Time can be converted into a Iso.ZonedDateTime by combining it with a Iso.Date and Iso.TimeZone using the toZonedDateTime() function. It can also be combined with a Iso.Date to yield a "zoneless" Iso.DateTime using the toDateTime() function.

Defined in

iso-types.ts:73

now

โ–ธ now(timeZone?): Time

This method gets the current wall-clock time according to the system settings. Optionally a time zone can be given in which the time is computed, instead of the current system time zone.

Parameters

NameTypeDescription
timeZone?stringThe time zone to get the current date and time in as a string. If not given, the current system time zone will be used.

Returns

Time

an Iso.Time string representing the current system time.

Defined in

types/ITimeFns.ts:14


fromNumbers

โ–ธ fromNumbers(hour?, minute?, second?, millisecond?): Time

Parameters

NameType
hour?number
minute?number
second?number
millisecond?number

Returns

Time

Defined in

types/ITimeFns.ts:15


isValid

โ–ธ isValid(time): time is Time

Parameters

NameType
timeunknown

Returns

time is Time

Defined in

types/ITimeFns.ts:16


assertIsValid

โ–ธ assertIsValid(time): asserts time is Time

Parameters

NameType
timeunknown

Returns

asserts time is Time

Defined in

types/ITimeFns.ts:17


getHour

โ–ธ getHour(time): number

Parameters

NameType
timeTime

Returns

number

Defined in

types/ITimeFns.ts:18


getMinute

โ–ธ getMinute(time): number

Parameters

NameType
timeTime

Returns

number

Defined in

types/ITimeFns.ts:19


getSecond

โ–ธ getSecond(time): number

Parameters

NameType
timeTime

Returns

number

Defined in

types/ITimeFns.ts:20


getMillisecond

โ–ธ getMillisecond(time): number

Parameters

NameType
timeTime

Returns

number

Defined in

types/ITimeFns.ts:21


with

โ–ธ with(time, timeLike, options?): Time

Parameters

NameType
timeTime
timeLikeObject
timeLike.hour?number
timeLike.minute?number
timeLike.second?number
timeLike.millisecond?number
options?Object
options.overflowTemporalOverflow

Returns

Time

Defined in

types/ITimeFns.ts:22


add

โ–ธ add(time, temporalDurationLike, options?): Time

Parameters

NameType
timeTime
temporalDurationLikeDuration | { years?: number ; months?: number ; weeks?: number ; days?: number ; hours?: number ; minutes?: number ; seconds?: number ; milliseconds?: number }
options?Object
options.overflow?TemporalOverflow

Returns

Time

Defined in

types/ITimeFns.ts:34


subtract

โ–ธ subtract(time, temporalDurationLike, options?): Time

Parameters

NameType
timeTime
temporalDurationLikeDuration | { years?: number ; months?: number ; weeks?: number ; days?: number ; hours?: number ; minutes?: number ; seconds?: number ; milliseconds?: number }
options?Object
options.overflow?TemporalOverflow

Returns

Time

Defined in

types/ITimeFns.ts:50


until

โ–ธ until(time, other, options?): Duration

Parameters

NameType
timeTime
otherTime
options?Object
options.largestUnit?TemporalSingularUnit | TemporalPluralUnit | "auto"
options.smallestUnit?TemporalSingularUnit | TemporalPluralUnit
options.roundingIncrement?number
options.roundingMode?TemporalRoundingMode

Returns

Duration

Defined in

types/ITimeFns.ts:66


since

โ–ธ since(time, other, options?): Duration

Parameters

NameType
timeTime
otherTime
options?Object
options.largestUnit?TemporalSingularUnit | TemporalPluralUnit | "auto"
options.smallestUnit?TemporalSingularUnit | TemporalPluralUnit
options.roundingIncrement?number
options.roundingMode?TemporalRoundingMode

Returns

Duration

Defined in

types/ITimeFns.ts:76


round

โ–ธ round(time, options): Time

Parameters

NameType
timeTime
optionsObject
options.smallestUnit"day" | "hour" | "minute" | "second" | "millisecond"
options.roundingIncrement?number
options.roundingMode?TemporalRoundingMode

Returns

Time

Defined in

types/ITimeFns.ts:86


equals

โ–ธ equals(time, other): boolean

Parameters

NameType
timeTime
otherTime

Returns

boolean

Defined in

types/ITimeFns.ts:94


toDateTime

โ–ธ toDateTime(time, date): DateTime

Parameters

NameType
timeTime
dateDate

Returns

DateTime

Defined in

types/ITimeFns.ts:95


toZonedDateTime

โ–ธ toZonedDateTime(time, item): ZonedDateTime

Parameters

NameType
timeTime
itemObject
item.dateDate
item.timeZonestring

Returns

ZonedDateTime

Defined in

types/ITimeFns.ts:96


getFields

โ–ธ getFields(time): TimeSlots

Parameters

NameType
timeTime

Returns

TimeSlots

Defined in

types/ITimeFns.ts:103


from

โ–ธ from(item, options?): Time

Parameters

NameType
itemany
options?Object
options.overflowTemporalOverflow

Returns

Time

Defined in

types/ITimeFns.ts:104


compare

โ–ธ compare(one, two): number

Parameters

NameType
oneTime
twoTime

Returns

number

Defined in

types/ITimeFns.ts:105


format

โ–ธ format(time, format): string

summary Format the ZonedDateTime.

description Return the formatted ZonedDateTime string in the given format.

The characters wrapped between two single quotes characters (') are escaped. Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. (see the last example)

Format of the string is based on Unicode Technical Standard #35: https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table with a few additions (see note 7 below the table).

Accepted patterns:

UnitPatternResult examplesNotes
AM, PMa..aaAM, PM
aaaam, pm
aaaaa.m., p.m.1
aaaaaa, p
AM, PM, noon, midnightb..bbAM, PM, noon, midnight
bbbam, pm, noon, midnight
bbbba.m., p.m., noon, midnight1
bbbbba, p, n, mi
Flexible day periodB..BBBat night, in the morning, ...
BBBBat night, in the morning, ...1
BBBBBat night, in the morning, ...
Hour [1-12]h1, 2, ..., 11, 12
ho1st, 2nd, ..., 11th, 12th3
hh01, 02, ..., 11, 12
Hour [0-23]H0, 1, 2, ..., 23
Ho0th, 1st, 2nd, ..., 23rd3
HH00, 01, 02, ..., 23
Hour [0-11]K1, 2, ..., 11, 0
Ko1st, 2nd, ..., 11th, 0th3
KK01, 02, ..., 11, 00
Hour [1-24]k24, 1, 2, ..., 23
ko24th, 1st, 2nd, ..., 23rd3
kk24, 01, 02, ..., 23
Minutem0, 1, ..., 59
mo0th, 1st, ..., 59th3
mm00, 01, ..., 59
Seconds0, 1, ..., 59
so0th, 1st, ..., 59th3
ss00, 01, ..., 59
Fraction of secondS0, 1, ..., 9
SS00, 01, ..., 99
SSS000, 001, ..., 999
SSSS...2
Long localized timep12:00 AM3
pp12:00:00 AM3

Notes:

  1. Any sequence of the identical letters is a pattern, unless it is escaped by the single quote characters (see below). If the sequence is longer than listed in table (e.g. EEEEEEEEEEE) the output will be the same as default pattern for this unit, usually the longest one (in case of ISO weekdays, EEEE). Default patterns for units are marked with "2" in the last column of the table.

    format("2017-11-06", 'MMM') //=> 'Nov'

    format("2017-11-06", 'MMMM') //=> 'November'

    format("2017-11-06", 'MMMMM') //=> 'N'

    format("2017-11-06", 'MMMMMM') //=> 'November'

    format("2017-11-06", 'MMMMMMM') //=> 'November'

  2. Some patterns could be unlimited length (such as yyyyyyyy). The output will be padded with zeros to match the length of the pattern.

    format("2017-11-06", 'yyyyyyyy') //=> '00002017'

  3. These patterns are not in the Unicode Technical Standard #35:

    • o: ordinal number modifier
    • p: long localized time
  • Characters are escaped using single quote symbols (').

example

// Escape string by single quote characters:
var result = format("15:00:00.000", "h 'o''clock'")
//=> "3 o'clock"

Parameters

NameTypeDescription
timeTimethe original date
formatstringthe string of tokens

Returns

string

the formatted date string

Defined in

types/ITimeFns.ts:199


chain

โ–ธ chain(time): ITimeChain

Parameters

NameType
timeTime

Returns

ITimeChain

Defined in

types/ITimeFns.ts:200