{"uid":"cap_-0RQ5UW2U1Gn2AI0VdS8O","slug":"locale-and-formatting-tools-relative-time-0aec5fa7","name":"Locale and Formatting Tools – Relative Time","description":"Relative time text such as '3 days ago' or 'tomorrow' for a signed value and unit in any locale.","url":"https://locale-tools.x402tookit.com/relative-time?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["value","unit"],"properties":{"unit":{"type":"string","description":"second, minute, hour, day, week, month, quarter or year"},"style":{"type":"string","description":"long (default), short or narrow"},"value":{"type":"number","description":"Signed amount: negative is the past, positive the future; absolute value up to 1e9"},"locale":{"type":"string","description":"BCP47 tag such as en, es, de, ja (default en-US, up to 60 characters)"},"numeric":{"type":"string","description":"always (default: '1 day ago') or auto ('yesterday')"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"asOf":{"type":["null","string"]},"parts":{"type":["array","null"],"items":{"type":"object","properties":{"type":{"type":["null","string"]},"unit":{"type":["null","string"]},"value":{"type":["null","string"]}}}},"locale":{"type":["null","string"]},"source":{"type":["null","string"]},"reasons":{"type":["array","null"]},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"direction":{"type":["null","string"]},"formatted":{"type":["null","string"]},"disclaimer":{"type":["null","string"]},"icuVersion":{"type":["null","string"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"cldrVersion":{"type":["null","string"]},"resolvedLocale":{"type":["null","string"]},"unicodeVersion":{"type":["null","string"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_6NKa-IJOai_KVXfOcWaCy","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Returns a localized relative-time string (e.g. '3 days ago' or 'tomorrow') for a signed numeric value and time unit in any BCP47 locale.","exampleAgentPrompt":"What's the localized relative-time string for -3 days (3 days ago) in French using the long style and auto numeric mode?","exampleUseCases":[{"title":"Multilingual social feed timestamps","prompt":"I need to show post timestamps as relative text in a user's language — can you format -2 hours in Japanese using the short style?"},{"title":"Localized 'days until' event countdown","prompt":"Our event is in 14 days — give me the relative-time text for +14 days in German with the long style and always-numeric mode."},{"title":"Narrow relative-time labels in compact UI","prompt":"I'm building a compact UI and need a narrow relative-time label for -1 week in Spanish — can you get that for me?"}],"resultDescription":"Returns a JSON object containing the formatted relative-time string (e.g. 'hace 3 días'), the resolved locale, direction (past/future), decomposed parts with types and values, ICU/CLDR/Unicode version info, and optional degradation or disclaimer flags.","failureModes":["Missing required 'value' or 'unit' parameters returns a 400-level error","Invalid or unrecognized BCP47 locale tag may fall back to a default locale with a degraded flag set","Unsupported unit strings (not one of second/minute/hour/day/week/month/quarter/year) cause validation errors","Value exceeding absolute magnitude of 1e9 is rejected","Payment not included or insufficient USDC triggers a 402 Payment Required response"],"whenToPreferThis":"Choose this endpoint when you need standards-compliant, ICU/CLDR-backed relative-time formatting across diverse locales — especially for multilingual apps, internationalised UIs, or any scenario where locale-sensitive output (auto 'yesterday' vs '1 day ago', RTL languages, narrow vs long styles) matters and rolling your own Intl.RelativeTimeFormat is impractical.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-11-02T12:30:33.557Z","isFirstParty":false,"canonicalSlug":"locale-and-formatting-tools-relative-time-0aec5fa7"}