← All Tools

Intl.RelativeTimeFormat Playground

Render “3 days ago”, “in 2 hours”, “next week”, etc. across any locale using the browser's built-in Intl.RelativeTimeFormat. Includes a date-diff auto-bucketing helper so you can paste two timestamps and get the most natural unit out.

Direct format

Pass a numeric value — positive is future, negative is past.

Output

Auto-bucket from a date diff

Pick the largest unit that produces a whole-number value ≥ 1. The result drives the formatter above when you click Use bucket.

Side-by-side across locales

Localenumeric: autonumeric: always

JS snippet


  

About

Intl.RelativeTimeFormat turns a numeric offset plus a unit (day, hour, …) into a localized phrase: “3 days ago”, “dans 3 jours”, “3 يوم مضت”. With numeric: 'auto' the formatter substitutes natural-language shorthand where available — you'll see “yesterday”, “next month”, “last year”. Only seven units are part of the spec, so a diff in milliseconds needs to be bucketed into the most natural one first; the helper above implements the common approach (largest unit with absolute value ≥ 1).