Date/Time Utilities

Relative Time

Converts timestamps into human-readable relative time descriptions like "2 days ago" or "in 3 hours". Use via MCP in Cursor or Windsurf for natural time formatting in AI workflows, or call GET /v1/datetime/relative with your timestamp. Returns consistent, localized descriptions that match user expectations. Perfect for chat interfaces, logs, and activity feeds where absolute timestamps feel robotic.

API Endpoint

GET /v1/datetime/relative

Code Examples

curl "https://tinyfn.io/v1/datetime/relative" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/datetime/relative', {
  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/relative',
    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 format a timestamp as relative time using MCP?

Pass your timestamp to the relative time tool in your MCP-enabled editor. It returns descriptions like '5 minutes ago', 'tomorrow', or 'last week' based on the current time.

What timestamp formats does the relative time API accept?

Accepts ISO 8601 strings, Unix timestamps (seconds or milliseconds), and standard date formats. The API normalizes input automatically.

Does relative time work for future dates?

Yes, future timestamps return forward-looking descriptions like 'in 2 hours', 'next week', or 'in 6 months'. Past dates use backward descriptions like 'yesterday' or '3 days ago'.

How precise are the relative time descriptions?

Returns contextually appropriate precision: seconds for very recent times, minutes/hours for same day, days for recent weeks, then months/years for older dates.

Can I customize the relative time output format or language?

The tool returns standard English descriptions optimized for readability. For custom formats or localization, you'd need to process the output or use additional formatting tools.

Try Relative Time Now

Get your free API key and start using Relative Time in seconds.

Get Free API Key