---
title: to_epoch() | Tiger Data Docs
description: Convert a timestamptz to a Unix epoch time
---

Since [1.16.0](https://github.com/timescale/timescaledb-toolkit/releases/tag/1.16.0)

Given a timestamptz, return the number of seconds since January 1, 1970 (the Unix epoch).

## Samples

Convert a date to a Unix epoch time:

```
SELECT to_epoch('2021-01-01 00:00:00+03'::timestamptz);
```

The output looks like this:

```
  to_epoch
------------
 1609448400
```

## Arguments

The syntax is:

```
SELECT to_epoch('<date>');
```

| Name   | Type        | Default | Required | Description                         |
| ------ | ----------- | ------- | -------- | ----------------------------------- |
| `date` | TIMESTAMPTZ | -       | ✔        | Timestamp to use to calculate epoch |

## Returns

| Column     | Type             | Description                                              |
| ---------- | ---------------- | -------------------------------------------------------- |
| `to_epoch` | DOUBLE PRECISION | The number of seconds since January 1, 1970 (Unix epoch) |
