JSON API

Exact time answers for machines.

Two unauthenticated GET endpoints. No SDK, no timezone guessing, and CORS is enabled for browser clients.

Base URLhttps://timediff.fyi/api
GET

Convert an epoch or ISO timestamp

Open UI
/api/epoch
value
A numeric Unix epoch. Use this or iso, never both.
unit
auto (default) uses a 100,000,000,000 threshold. Set seconds or milliseconds for ambiguous early dates.
iso
An ISO 8601 timestamp ending in Z or an explicit numeric offset.

Epoch → date

curl -s "https://timediff.fyi/api/epoch?value=0&unit=seconds"
200 response
{
  "ok": true,
  "data": {
    "input": 0,
    "input_unit": "seconds",
    "seconds": 0,
    "milliseconds": 0,
    "iso": "1970-01-01T00:00:00.000Z",
    "utc": "Thu, 01 Jan 1970 00:00:00 GMT"
  }
}

Date → epoch

curl -s "https://timediff.fyi/api/epoch?iso=2026-08-22T10%3A30%3A00%2B01%3A00"
GET

Difference between two timestamps

Open UI
/api/diff
from
The starting ISO 8601 timestamp with Z or a numeric offset.
to
The ending ISO 8601 timestamp with Z or a numeric offset.
curl -s "https://timediff.fyi/api/diff?from=1970-01-01T00%3A00%3A00Z&to=1970-01-02T01%3A30%3A00Z"
200 response
{
  "ok": true,
  "data": {
    "from": "1970-01-01T00:00:00.000Z",
    "to": "1970-01-02T01:30:00.000Z",
    "direction": "after",
    "sign": 1,
    "milliseconds": 91800000,
    "seconds": 91800,
    "human": "1 day, 1 hour, 30 minutes",
    "iso_duration": "P1DT1H30M"
  }
}
Errors & transport

Predictable by default

Invalid or missing inputs return HTTP 400 with a stable error object. Successful responses are cacheable; errors are not. Every endpoint accepts OPTIONS and returns Access-Control-Allow-Origin: *.

400 response
{
  "ok": false,
  "error": {
    "code": "INVALID_TIMESTAMP",
    "message": "From timestamp must include Z or an explicit offset such as +01:00."
  }
}