Snipget.ai

Duration between two datetimes

Exact
dates_diff

Deterministic and authoritative — the canonical answer for this input.

Duration between two ISO 8601 datetimes (end − start). Returns totals in seconds/minutes/hours/days/weeks, a whole-part calendar breakdown (years/months/days...), and a direction (past/future/same). Processing multiple inputs? Use `dates_diff_batch` to do up to 1000 in one call.

Parameters

startstringrequired

ISO 8601 start datetime.

endstringrequired

ISO 8601 end datetime.

Call it

curl -X POST https://api.snipget.ai/v1/dates/diff \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"start":"2024-01-01","end":"2024-01-08"}'

The Batch tab sends up to 1000 inputs in one call via /v1/dates/diff/batch.

Example response

{
  "input": [
    "2024-01-01",
    "2024-01-08"
  ],
  "is_valid": true,
  "direction": "future",
  "total_seconds": 604800,
  "total_minutes": 10080,
  "total_hours": 168,
  "total_days": 7,
  "total_weeks": 1,
  "calendar": {
    "years": 0,
    "months": 0,
    "days": 7,
    "hours": 0,
    "minutes": 0,
    "seconds": 0
  }
}

FAQ

What does diff give me?

The gap between two dates, expressed several ways at once: total seconds, minutes, hours, days, and weeks, plus a calendar breakdown into whole years, months, and days. It also says whether end is in the future or past relative to start.

Why not subtract the dates myself?

Getting both an exact total (like 168 hours) and a human breakdown (like 2 months, 3 days) right is fiddly, especially across months of different lengths. This tool answers both deterministically.

Does it handle timezones?

Yes. If one date has a timezone and the other does not, the plain one is treated as UTC so the two are comparable. For a clean result, give both ends the same form.

Is the answer exact?

Yes. It is deterministic and authoritative. The same pair of dates always returns the same totals and breakdown.

What if one date is invalid?

You get confidence 0 with a why_invalid reason instead of an error. Both start and end are required.

Related tools