> ## Documentation Index
> Fetch the complete documentation index at: https://axiom.co/docs/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://axiom.co/docs/feedback

```json
{
  "path": "/apl/scalar-functions/datetime-functions/unixtime-seconds-todatetime",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# unixtime_seconds_todatetime

> This page explains how to use the unixtime_seconds_todatetime function in APL.

`unixtime_seconds_todatetime` converts a Unix timestamp that’s expressed in whole seconds since 1970-01-01 00:00:00 UTC to an APL [datetime value](/apl/data-types/scalar-data-types).

Use the function whenever you ingest data that stores time as epoch seconds (for example, JSON logs from NGINX or metrics that follow the StatsD line protocol). Converting to `datetime` lets you bin, filter, and visualize events with the rest of your time-series data.

## For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.

<AccordionGroup>
  <Accordion title="Splunk SPL users">
    `unixtime_seconds_todatetime` replaces the combination of `eval strftime` / `strptime` that you normally use in Splunk. Pass the epoch value directly and APL returns a `datetime`.

    <CodeGroup>
      ```sql Splunk example theme={null}
      eval event_time = strftime(epoch, "%Y-%m-%dT%H:%M:%S")
      ```

      ```kusto APL equivalent theme={null}
      extend event_time = unixtime_seconds_todatetime(epoch)
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="ANSI SQL users">
    Most ANSI SQL engines call this conversion with `FROM_UNIXTIME` or `TO_TIMESTAMP`. The APL version has the same single-argument signature, returns a full `datetime`, and automatically interprets the input as seconds (not milliseconds).

    <CodeGroup>
      ```sql SQL example theme={null}
      SELECT TO_TIMESTAMP(epoch_seconds) AS event_time FROM events;
      ```

      ```kusto APL equivalent theme={null}
      ['events']
      | extend event_time = unixtime_seconds_todatetime(epoch_seconds)
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

## Usage

### Syntax

```kusto theme={null}
unixtime_seconds_todatetime(seconds)
```

### Parameters

| Name      | Type            | Description                                                        |
| --------- | --------------- | ------------------------------------------------------------------ |
| `seconds` | `int` or `long` | Whole seconds since the Unix epoch. Fractional input is truncated. |

### Returns

A `datetime` value that represents the given epoch seconds at UTC precision (1 second).

## Use case example

The HTTP access logs keep the timestamp as epoch seconds and you want to convert the values to datetime.

**Query**

```kusto theme={null}
['sample-http-logs']
| extend epoch_seconds = toint(datetime_diff('Second', _time, datetime(1970-01-01)))
| extend datetime_standard = unixtime_seconds_todatetime(epoch_seconds)
| project _time, epoch_seconds, datetime_standard
```

[Run in Playground](https://play.axiom.co/axiom-play-qf1k/query?initForm=%7B%22apl%22%3A%22%5B'sample-http-logs'%5D%20%7C%20extend%20epoch_seconds%20%3D%20toint\(datetime_diff\('Second'%2C%20_time%2C%20datetime\(1970-01-01\)\)\)%20%7C%20extend%20datetime_standard%20%3D%20unixtime_seconds_todatetime\(epoch_seconds\)%20%7C%20project%20_time%2C%20epoch_seconds%2C%20datetime_standard%22%7D)

**Output**

| \_time           | epoch\_seconds | datetime\_standard   |
| ---------------- | -------------- | -------------------- |
| May 15, 12:09:22 | 1,747,303,762  | 2025-05-15T10:09:22Z |

This query converts the timestamp to epoch seconds and then back to datetime for demonstration purposes.

## List of related functions

* [unixtime\_microseconds\_todatetime](/apl/scalar-functions/datetime-functions/unixtime-microseconds-todatetime): Converts a Unix timestamp expressed in whole microseconds to an APL `datetime` value.
* [unixtime\_milliseconds\_todatetime](/apl/scalar-functions/datetime-functions/unixtime-milliseconds-todatetime): Converts a Unix timestamp expressed in whole milliseconds to an APL `datetime` value.
* [unixtime\_nanoseconds\_todatetime](/apl/scalar-functions/datetime-functions/unixtime-nanoseconds-todatetime): Converts a Unix timestamp expressed in whole nanoseconds to an APL `datetime` value.
