---
title: parseTimestamp
description: |
  Returns a parsed timestamp from a date or time string, enabling use of DataPrime's time functions.

  !!! note
      If the string cannot be parsed (for example, if it does not match the expected format), the function returns `null`.
url: https://coralogix.com/docs/dataprime/language-reference/functions-reference/time/parsetimestamp/
product: dataengine
feature: DataPrime Language
feature_id: dataprime-language
feature_identifier: dataengine/dataprime-language
last_updated: '2026-10-21'
---

# `parseTimestamp`

## Description

Returns a parsed timestamp from a date or time string, enabling use of DataPrime's time functions.

Note

If the string cannot be parsed (for example, if it does not match the expected format), the function returns `null`.

## Syntax

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

* Function notation
* Method notation

```
parseTimestamp(string: string, format?: string, tz?: string): timestamp
```

```
(string: string).parseTimestamp(format?: string, tz?: string): timestamp
```

## Arguments

| Name     | Type     | Required  | Description                                                                                             |
| -------- | -------- | --------- | ------------------------------------------------------------------------------------------------------- |
| `string` | `string` | **true**  | The string to parse into a timestamp                                                                    |
| `format` | `string` | **false** | The format of the input string. Defaults to `auto`, which attempts to match against well-known formats. |
| `tz`     | `string` | **false** | A valid time zone string                                                                                |

## Example 1

**Use case: Parse a simple date string using default format**

### Example query

* Function notation
* Method notation

```
choose parseTimestamp('2023-04-05') as ts
```

```
choose '2023-04-05'.parseTimestamp() as ts
```

### Example output

```
{

    "ts": 1680652800000000000

}
```

## Example 2

**Use case: Parse a US-style date**

### Example query

* Function notation
* Method notation

```
choose parseTimestamp('04/05/23', '%D') as ts
```

```
choose '04/05/23'.parseTimestamp('%D') as ts
```

### Example output

```
{

    "ts": 1680652800000000000

}
```

## Example 3

**Use case 3: Parse date and time with units**

### Example query

* Function notation
* Method notation

```
choose parseTimestamp('2023-04-05 16h07m', '%F %Hh%Mm') as ts
```

```
choose '2023-04-05 16h07m'.parseTimestamp('%F %Hh%Mm') as ts
```

### Example output

```
{

    "ts": 1680710820000000000

}
```

## Example 4

**Use case 4: Parse a Unix timestamp in seconds**

### Example query

* Function notation
* Method notation

```
choose parseTimestamp('1680710853', 'timestamp_second') as ts
```

```
choose '1680710853'.parseTimestamp('timestamp_second') as ts
```

### Example output

```
{

    "ts": 1680710853000000000

}
```

## Example 5

**Use case 5: Parse inconsistent formats with multiple options**

Some logs contain timestamps in different formats. Provide a `|`-separated list of formats to handle them all.

### Example data

```
{ "ts": "1680710853123", "app": "app1" },

{ "ts": "2023-04-05", "app": "app2" },

{ "ts": "2023-04-05T16:07:33.123Z", "app": "app3" }
```

### Example query

* Function notation
* Method notation

```
create ts_parsed from parseTimestamp(ts, 'timestamp_second|%Y-%m-%d|iso8601')
```

```
create ts_parsed from ts.parseTimestamp('timestamp_second|%Y-%m-%d|iso8601')
```

### Example output

```
{ "ts": "1680710853123", "app": "app1", "ts_parsed": 1680710853123000000 },

{ "ts": "2023-04-05", "app": "app2", "ts_parsed": 1680652800000000000 },

{ "ts": "2023-04-05T16:07:33.123Z", "app": "app3", "ts_parsed": 1680710853123000000 }
```
