# `toIso8601DateTime`

## Description

Warning

`toIso8601DateTime` is depricated. Use [`formatTimestamp`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/time/formattimestamp/index.md) instead.

Returns a timestamp formatted as an ISO 8601 string (e.g. `2023-08-11T07:29:17.634Z`). This function supports nanosecond precision.

## Syntax

Like many functions in DataPrime, `toIso8601DateTime` supports [two notations](https://coralogix.com/docs/dataprime/language-reference/functions-reference/index.md), **function** and **method** notation. These interchangeable forms allow flexibility in how you structure expressions.

```dataprime
toIso8601DateTime(timestamp: timestamp): string
```

```dataprime
(timestamp: timestamp).toIso8601DateTime(): string
```

## Arguments

| Name      | Type      | Required | Description                         |
| --------- | --------- | -------- | ----------------------------------- |
| timestamp | timestamp | **true** | The timestamp to format in ISO 8601 |

## Example

**Use case: Convert a timestamp into ISO 8601 format**

### Example query

```dataprime
create formatted_ts from toIso8601DateTime($m.timestamp)
```

```dataprime
create formatted_ts from $m.timestamp.toIso8601DateTime()
```

### Example output

```json
{
  "formatted_ts": "2023-08-11T07:29:17.634Z"
}
```
