{"version":"1.0","type":"rich","title":"JavaScript/TypeScript: print relative times with no dependencies. e.g. \"3 minutes ago\", \"1 week ago\"","description":"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.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-b99e58763cffdbf306af9bc2b62e3d18?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}