Agent402 / tools / date-diff

Date difference

$0.001 per call · POST /api/date-diff · USDC via x402

Difference between two dates/times in ms, seconds, minutes, hours, days, and a human summary.

Input

FieldTypeDescription
from *anyStart (epoch/ISO)
toanyEnd (epoch/ISO, default now)

Example output

{
  "millis": 13948800000,
  "days": 161.4,
  "human": "161d 10h"
}

Try it — see the 402 challenge (free)

curl -i -X POST https://agent402.tools/api/date-diff \
  -H "Content-Type: application/json" \
  -d '{"from":"2026-01-01","to":"2026-06-11T10:00:00Z"}'

The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/date-diff", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "from": "2026-01-01",
    "to": "2026-06-11T10:00:00Z"
  }),
});

Related tools

Current time

$0.001 · GET /api/time

Current time: UTC ISO, epoch seconds/ms, day of week/year, ISO week — optionally rendered in any IANA timezone…

Time convert

$0.001 · POST /api/time-convert

Convert between epoch (s or ms), ISO 8601, and any IANA timezone. Give a value, get every representation back.…

Cron next runs

$0.002 · POST /api/cron-next

Parse a 5-field cron expression and return the next N run times (UTC).…