Tell us what works and what could be better. We read every submission.
@TommasoAmici·1 public viz
This example demonstrates how to format relative time strings like “3 minutes ago” or “1 week ago” using the native JavaScript `Intl.RelativeTimeFormat` API. It defines a `formatDate` function that calculates the time difference between a given `Date` and the current moment, then selects the appropriate unit—seconds, minutes, hours, days, weeks, months, or years—based on the elapsed duration. The code uses no external dependencies, relying solely on TypeScript and the built-in `Intl.RelativeTimeFormat` with `numeric: "auto"` for human-friendly output.