# Instant

`import { Instant } from "destack:time";`

Temporal instant.

```ds title="Instant"
export class Instant {
    static fromEpochMilliseconds(epochMilliseconds: float64): Instant;
    static fromEpochNanoseconds(epochNanoseconds: bigint): Instant;
    static from(item: Instant | string): Instant;
    static compare(one: Instant | string, two: Instant | string): -1 | 0 | 1;
    constructor(epochNanoseconds: bigint);
    get epochMilliseconds(): float64;
    get epochNanoseconds(): bigint;
    equals(other: Instant | string): boolean;
    add(durationLike: Omit<Duration | DurationLike, "years" | "months" | "weeks" | "days"> | string): Instant;
    subtract(durationLike: Omit<Duration | DurationLike, "years" | "months" | "weeks" | "days"> | string): Instant;
    until(other: Instant | string, options?: DifferenceOptions<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"> | undefined): Duration;
    since(other: Instant | string, options?: DifferenceOptions<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"> | undefined): Duration;
    round(roundTo: SmallestUnit<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"> | { smallestUnit: SmallestUnit<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">; roundingIncrement?: float64; roundingMode?: RoundingMode }): Instant;
    toZonedDateTimeISO(timeZone: string | ZonedDateTime): ZonedDateTime;
    toLocaleString(locales?: LocalesArgument | undefined, options?: DateTimeFormatOptions | undefined): Cow<"frame", string>;
    toJSON(): Cow<"frame", string>;
    toString(options?: InstantToStringOptions | undefined): Cow<"frame", string>;
    valueOf(): never;
}
```

[language/library/src/time/instant.ds:16:124](https://github.com/destack-sh/destack/blob/main/language/library/src/time/instant.ds#L16-L124)

## Members

### `static fromEpochMilliseconds(epochMilliseconds: float64): Instant`

Create an instant from epoch milliseconds.

### `static fromEpochNanoseconds(epochNanoseconds: bigint): Instant`

Create an instant from epoch nanoseconds.

### `static from(item: Instant | string): Instant`

Create an instant from another instant or string.

### `static compare(one: Instant | string, two: Instant | string): -1 | 0 | 1`

Compare two instants.

### `constructor(epochNanoseconds: bigint)`

Create an instant.

### `get epochMilliseconds(): float64`

Epoch milliseconds.

### `get epochNanoseconds(): bigint`

Epoch nanoseconds.

### `equals(other: Instant | string): boolean`

Return true when this instant equals `other`.

### `add(durationLike: Omit<Duration | DurationLike, "years" | "months" | "weeks" | "days"> | string): Instant`

Add a time duration.

### `subtract(durationLike: Omit<Duration | DurationLike, "years" | "months" | "weeks" | "days"> | string): Instant`

Subtract a time duration.

### `until(other: Instant | string, options?: DifferenceOptions<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"> | undefined): Duration`

Return the duration until `other`.

### `since(other: Instant | string, options?: DifferenceOptions<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"> | undefined): Duration`

Return the duration since `other`.

### `round(roundTo: SmallestUnit<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"> | { smallestUnit: SmallestUnit<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">; roundingIncrement?: float64; roundingMode?: RoundingMode }): Instant`

Round this instant.

### `toZonedDateTimeISO(timeZone: string | ZonedDateTime): ZonedDateTime`

Convert this instant into an ISO zoned date-time.

### `toLocaleString(locales?: LocalesArgument | undefined, options?: DateTimeFormatOptions | undefined): Cow<"frame", string>`

Return a locale-aware string.

### `toJSON(): Cow<"frame", string>`

Return a JSON string.

### `toString(options?: InstantToStringOptions | undefined): Cow<"frame", string>`

Return an ISO string.

### `valueOf(): never`

Reject numeric coercion.
