---
title: Convert a timestamp
description: Convert Unix timestamps into readable date and time strings with `formatTimestamp`, replacing the deprecated `toIso8601DateTime`.
url: https://coralogix.com/docs/dataprime/cookbook/convert_timestamp/
product: dataengine
feature: DataPrime Language
feature_id: dataprime-language
feature_identifier: dataengine/dataprime-language
last_updated: '2026-11-02'
---

# Convert a timestamp

## 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.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.

```
// 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.md) in older queries. This function will accepts a timestamp as an argument and returns the corresponding `ISO 8601` formatted time string.

```
>>> 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.md) with a parsed or converted timestamp for clean, flexible datetime formatting. Avoid `toIso8601DateTime()`.
