# Instant Class

## Instant Class

The `Instant` class is a fundamental component of B2Win Suite Scripting, allowing you to work with instants in time. This class provides methods for creating and manipulating time-related data.

### Static Methods

* `Instant.now(): Instant`

**Description**: Returns an instance representing the current instant.

Example:

```typescript
var currentInstant = Instant.now();
```

***

* `Instant.parse(text: String)`

**Description**: Parses a string and returns an instance of `Instant.`

Example:

```typescript
var parsedInstant = Instant.parse("2023-10-20T12:00:00Z");
```

***

### Comparison Methods

* `isBefore(otherInstant: Instant)`

**Description**: Compares this `Instant` with another `Instant` and returns `true` if it is before the other instant or false otherwise.

Example:

```typescript
var instantA = Instant.parse("2023-10-20T08:00:00Z"); // parse Instant A
var instantB = Instant.parse("2023-10-20T09:00:00Z"); // parse Instant B

var isBefore = instantA.isBefore(instantB);

if (isBefore) {
    // Do something when instantA is before instantB
    return "instantA is before instantB";
} else {
    // Do something when instantA is not before instantB
    return "instantA is not before instantB";
}
```

***

* #### `isAfter(otherInstant: Instant)`

**Description**: Compares this `Instant` with another `Instant` and returns `true` if it is after the other instant or false otherwise.

Example:

```typescript
var isAfter = instantA.isAfter(instantB);

if (isAfter) {
    // Do something when instantA is after instantB
    return "instantA is after instantB";
} else {
    // Do something when instantA is not after instantB
    return "instantA is not after instantB";
}
```

***

### Conversion Methods

* #### `toEpochMilli()`

**Description**: Converts this `Instant` to the number of milliseconds since the epoch (00:00:00 UTC on 1 January 1970) and returns the value in type `Long.`

Example:

```typescript
var myInstant = Instant.parse("2023-10-20T08:00:00Z");
var epochMillis = myInstant.toEpochMilli();
```

***

* #### `toString()`

**Description**: Converts this `Instant` to a string representation and returns it.

Example:

```typescript
var myInstant = Instant.parse("2023-10-20T08:00:00Z");
var instantString = myInstant.toString();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.b2winsuite.com/5.2/scripting/non-static-classes/instant-class.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
