## Problem / Use case

You have a Unix timestamp (or timestamp string) and want to display it in a human-readable format for logs, alerts, or dashboards.

There are several ways that this conversion can be performed. You can choose the one that best fits your use case.

## `formatTimestamp`

[`formatTimestamp`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/time/formattimestamp/index.md) gives the user the flexibility to specify the output format. The first parameter is the timestamp and the second is the format. You ca use `iso8601` without having to manually specify that format.

```dataprime
// date only
>>> formatTimestamp(1745905982439, '%Y-%m-%d')
'2025-04-29'

// time only
>>> formatTimestamp(1745905982439, '%H:%M:%S')
'05:53:02'

// date and time
>>> formatTimestamp(1745905982439, '%F %H:%M:%S')
'2025-04-29 05:53:02'

// iso8601 format (same as toIso8601DateTime)
>>> formatTimestamp(1745905982439, 'iso8601')
'2025-04-29T05:53:02.439Z'
```

## Old deprecated method - `toIso8601DateTime`

This shouldn’t be used, but you might see [`toIso8601DateTime`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/time/toiso8601datetime/index.md) in older queries. This function will accepts a timestamp as an argument and returns the corresponding `ISO 8601` formatted time string.

```dataprime
>>> toIso8601DateTime(1745905982439)
'2025-04-29T05:53:02.439Z'
```

Since it’s deprecated use `formatTimestamp(<timestamp>, 'iso8601')` instead.

## TL;DR

Use [`formatTimestamp`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/time/formattimestamp/index.md) with a parsed or converted timestamp for clean, flexible datetime formatting. Avoid `toIso8601DateTime()`.
