---
title: "Datetimes"
description: "Klaviyo Developers | Learn how to format datetimes for Klaviyo's APIs."
url: "https://developers.klaviyo.com/en/docs/datetimes_"
category: "Klaviyo API essentials"
lastUpdated: "2023-08-14"
related: ["https://developers.klaviyo.com/en/docs/llms.txt","https://developers.klaviyo.com/en/docs/json_api_feature_guides.md"]
---

# Datetimes

> This is the Markdown version of https://developers.klaviyo.com/en/docs/datetimes_

Klaviyo Developers | Learn how to format datetimes for Klaviyo's APIs.

## Date and timestamp support

Note that event datetimes sent via the legacy v1/v2 endpoints support Unix timestamps in addition to datetime ISO 8601 formats. However, our new APIs do not support Unix timestamps. It is recommended that you convert the Unix timestamp to a supported ISO 8601 format. See the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString" target="_blank">MDN docs on the toISOString() method</a> for more details on conversion.

## Datetime formatting

All datetimes across all new APIs in URLs, requests, and response bodies must use the <a href="https://datatracker.ietf.org/doc/html/rfc3339" target="_blank">ISO 8601 RFC 3339</a> format, such as `YYYY-MM-DDTHH:MM:SS.[mmm]`. Note that the letters used in the datetime syntax must always be uppercase. Some examples include:

- `2023-08-15T12:30:00`
- `2023-08-15T12:30:00Z`
- `2023-08-15 12:30:00Z`
- `2023-08-15T12:30:00+03:00`

For more information on recognized formats, refer to our <a href="https://developers.klaviyo.com/en/docs/acceptable_date_and_timestamp_formats_for_profile_and_event_properties.md" target="_blank">acceptable date and timestamp formats guide</a> for profile and event properties.

## URI encoding

Datetimes can contain non-URL-safe characters. To combat this, we recommend that you always URI-encode your datetime values. Refer to the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent" target="_blank">MDN docs on encodeURIComponent</a> for more details.

## Example request and response

In this example, we have requested all events that have a datetime greater than `2023-08-07T12:30:00.710Z:`

```curl Request
curl --request GET \
     --url 'https://a.klaviyo.com/api/events/?filter=greater-than(datetime,2023-08-07T12:30:00.710Z)' \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/json' \
     --header 'revision: 2023-07-15'
```
```json Response
{
    "data": [
        {
            "type": "event",
            "id": "4vGfpcpPRGL",
            "attributes": {
                "timestamp": 1692028246,
                "event_properties": {
                    "custom_value": "newer event time value",
                    "$event_id": "YjpZcE"
                },
                "datetime": "2023-08-14 15:50:46+00:00",
                "uuid": "55084f00-3aba-11ee-8001-a3e96a3d92dc"
            },
            "relationships": {
                "profile": {
                    "data": {
                        "type": "profile",
                        "id": "01H7TBW70G8RYXHF9D91K4W72J"
                    },
                    "links": {
                        "self": "https://a.klaviyo.com/api/events/4vGfpcpPRGL/relationships/profile/",
                        "related": "https://a.klaviyo.com/api/events/4vGfpcpPRGL/profile/"
                    }
                },
                "metric": {
                    "data": {
                        "type": "metric",
                        "id": "TQpx2b"
                    },
                    "links": {
                        "self": "https://a.klaviyo.com/api/events/4vGfpcpPRGL/relationships/metric/",
                        "related": "https://a.klaviyo.com/api/events/4vGfpcpPRGL/metric/"
                    }
                }
            },
            "links": {
                "self": "https://a.klaviyo.com/api/events/4vGfpcpPRGL/"
            }
        },
        {
            "type": "event",
            "id": "4uQsGyFKUGn",
            "attributes": {
                "timestamp": 1691523702,
                "event_properties": {
                    "custom_value": "custom val",
                    "$event_id": "1691523702"
                },
                "datetime": "2023-08-08 19:41:42+00:00",
                "uuid": "995f9f00-3623-11ee-8001-b91e24a90599"
            },
            "relationships": {
                "profile": {
                    "data": {
                        "type": "profile",
                        "id": "01H6PJY17J72TV4EWXZPS1XYX7"
                    },
                    "links": {
                        "self": "https://a.klaviyo.com/api/events/4uQsGyFKUGn/relationships/profile/",
                        "related": "https://a.klaviyo.com/api/events/4uQsGyFKUGn/profile/"
                    }
                },
                "metric": {
                    "data": {
                        "type": "metric",
                        "id": "QV8sPg"
                    },
                    "links": {
                        "self": "https://a.klaviyo.com/api/events/4uQsGyFKUGn/relationships/metric/",
                        "related": "https://a.klaviyo.com/api/events/4uQsGyFKUGn/metric/"
                    }
                }
            },
            "links": {
                "self": "https://a.klaviyo.com/api/events/4uQsGyFKUGn/"
            }
        }
    ],
    "links": {
        "self": "https://a.klaviyo.com/api/events/?filter=greater-than(datetime,2023-08-07T12:30:00.710Z)",
        "next": null,
        "prev": null
    }
}
```

## Additional resources

- <a href="https://developers.klaviyo.com/en/docs/acceptable_date_and_timestamp_formats_for_profile_and_event_properties.md" target="_blank">Acceptable date and timestamp formats for profile and event properties</a>
- <a href="https://help.klaviyo.com/hc/en-us/articles/360039859932" target="_blank">Format dates for CSV files</a>
