Converts seconds into human-readable relative time strings like "2 hours ago" or "in 3 days". Available via MCP in Cursor and other AI editors, or REST at GET /v1/format/relative-time. Pass positive values for future times, negative for past. Perfect for chat timestamps, activity feeds, or any UI needing friendly time formatting instead of raw numbers.
curl "https://tinyfn.io/v1/format/relative-time" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/format/relative-time', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/format/relative-time',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's formatting tools:
{
"mcpServers": {
"tinyfn-format": {
"url": "https://tinyfn.io/mcp/format",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Call the format_relative_time tool with your seconds value. Negative numbers show past times ('5 minutes ago'), positive show future ('in 2 hours').
Relative time shows duration from now ('3 days ago') while timestamps show exact dates ('2024-01-15'). Use relative for recent events, timestamps for historical data.
Automatically selects appropriate units from seconds to years. Returns the most readable format - '90 seconds' becomes '1 minute', '25 hours' becomes '1 day'.
The formatter returns English phrases only. For internationalization, you'll need to translate the output or use locale-specific formatting libraries.
Zero returns 'now', very small values round to 'just now', and extremely large values use years. Handles both positive and negative inputs gracefully.
Get your free API key and start using Format Relative Time in seconds.
Get Free API Key