Date/Time Utilities

Date Diff

Calculate precise time differences between two dates with multiple unit options. Access via MCP in Cursor or Windsurf, or GET /v1/datetime/diff REST endpoint. Returns differences in days, hours, minutes, seconds, or milliseconds. Perfect for deadline tracking, age calculations, or duration analytics in AI workflows.

API Endpoint

GET /v1/datetime/diff

Code Examples

curl "https://tinyfn.io/v1/datetime/diff" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/datetime/diff', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/datetime/diff',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's date/time tools:

{
  "mcpServers": {
    "tinyfn-datetime": {
      "url": "https://tinyfn.io/mcp/datetime",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I calculate the difference between two dates?

Send a GET request to /v1/datetime/diff with start_date and end_date parameters. The tool returns the difference in your specified unit (days, hours, minutes, seconds, or milliseconds).

What date formats does the date diff tool accept?

Accepts ISO 8601 format (2024-01-15T10:30:00Z), Unix timestamps, and standard date strings. Always returns deterministic results regardless of input format.

Can I get negative values if the end date is before start date?

Yes, the tool returns negative values when end_date is earlier than start_date. This is useful for detecting overdue deadlines or past events.

How can MCP agents use date diff for project management?

AI agents in Cursor or Cline can calculate project durations, sprint lengths, or deadline proximity. Combine with other datetime tools for comprehensive timeline analysis.

Does date diff account for time zones and daylight saving?

The tool performs UTC-based calculations for consistency. Convert dates to your target timezone before calling if timezone-aware differences are needed.

Try Date Diff Now

Get your free API key and start using Date Diff in seconds.

Get Free API Key