Calculate precise time differences between two datetime values, returning results in multiple units (seconds, minutes, hours, days). Use via MCP in Cursor or Claude Code, or call GET /v1/time/difference directly. Perfect for scheduling logic, SLA tracking, or duration calculations. Handles timezone-aware inputs and provides both absolute and signed differences.
curl "https://tinyfn.io/v1/time/difference" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/time/difference', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/time/difference',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's time/timezone tools:
{
"mcpServers": {
"tinyfn-time": {
"url": "https://tinyfn.io/mcp/time",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Pass two datetime strings to the time difference tool in your MCP-enabled editor. It returns the difference in seconds, minutes, hours, and days, plus whether the first date is before or after the second.
Accepts ISO 8601 formats, Unix timestamps, and common date strings. Timezone information is preserved when provided, otherwise UTC is assumed.
Yes, the tool returns signed differences. If the first datetime is earlier than the second, you'll get negative values indicating the first date is in the past relative to the second.
Extremely accurate. The tool properly handles timezone offsets, daylight saving time transitions, and leap seconds when calculating differences between timezone-aware datetimes.
This tool handles complex scenarios like timezone conversions, DST changes, and provides results in multiple units simultaneously. Simple subtraction often fails with timezone-aware dates or gives incorrect results during DST transitions.
Get your free API key and start using Time Difference in seconds.
Get Free API Key