# Convert a timestamp

Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Fcookbook%2Fconvert_timestamp.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Fcookbook%2Fconvert_timestamp.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

## Problem / Use case[​](#problem--use-case "Direct link to 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 "Direct link to formattimestamp")

[`formatTimestamp`](https://docs-docusaurus.kinsta.page/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`[​](#old-deprecated-method---toiso8601datetime "Direct link to old-deprecated-method---toiso8601datetime")

This shouldn’t be used, but you might see [`toIso8601DateTime`](https://docs-docusaurus.kinsta.page/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[​](#tldr "Direct link to TL;DR")

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