Date & Time 1 credit COMPUTE

Date Diff API

Calculate the precise difference between two dates via REST API. Returns the difference broken down into years, months, weeks, days, hours, minutes, and seconds — and handles timezone-aware date strings correctly.

Try it live →

How it works

POST two date strings (ISO 8601, Unix timestamps, or natural language dates). The API parses both, computes the absolute difference, and returns it in multiple units simultaneously.

Use cases

API Reference

POST https://slopshop.gg/v1/date-diff
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Input parameters

ParameterTypeRequiredDescription
input string | object required The input data to process

Example response

{
  "data": {
    "result": "2025-01-15T10:30:00.000Z",
    "formatted": "January 15, 2025"
  },
  "meta": {
    "credits_used": 1,
    "engine": "real",
    "ms": 4
  }
}

Examples

Three real-world scenarios showing how developers use Date Diff in production.

Example 1
Calculate user account age
Find how long a user has been a customer since their signup date.
curl -X POST https://slopshop.gg/v1/date-diff \
  -H "Authorization: Bearer $SLOPSHOP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"date1": "2022-03-15", "date2": "2025-03-26"}'
Example 2
Compute SLA duration
Calculate how long a support ticket was open from open to close timestamps.
curl -X POST https://slopshop.gg/v1/date-diff \
  -H "Authorization: Bearer $SLOPSHOP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"date1": "2025-03-24T09:15:00Z", "date2": "2025-03-26T14:30:00Z"}'
Example 3
Subscription duration check
Determine if a subscription has been active for more than 30 days.
curl -X POST https://slopshop.gg/v1/date-diff \
  -H "Authorization: Bearer $SLOPSHOP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"date1": "2025-02-01", "date2": "2025-03-26"}'

Code examples

curl

curl -X POST https://slopshop.gg/v1/date-diff \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input": "your data here"}'

Python

import requests

response = requests.post(
    "https://slopshop.gg/v1/date-diff",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={"input": "your data here"}
)
result = response.json()
print(result["data"])

Node.js

const response = await fetch("https://slopshop.gg/v1/date-diff", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ input: "your data here" })
});
const { data } = await response.json();
console.log(data);

CLI

# Install the Slopshop CLI
npm install -g slopshop

# Set your API key
export SLOPSHOP_KEY=your_api_key

# Call date-diff
slop date-diff '{"input": "your data here"}'

Pricing

Credits per call
1
credits
Cost per call
$0.001
at Starter tier
Tier
COMPUTE
Pure compute

Credits are purchased in bundles starting at $1 for 1,000 credits. All compute APIs like this one use 1 credit per call — that's $0.001. See all pricing tiers.

Related APIs in Date & Time

View the full API catalog · Try in playground · Documentation