Regrettably Safari is—yet again—lacking with support, but in the meantime there is a polyfill.
1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
2. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Twice I’ve started with it, twice I’ve tossed it out because in the end it didn’t help my code at all. (Both times I only cared about English, so its replacement which did a better job of formatting values for my situation took pretty much no extra code—for exact equivalence, formatter.format(-n, 'day') for known positive n becomes a simple ternary, `n == 1 ? '1 day ago' : '${n} days ago'` (or if the formatter has the {numeric: 'auto'} option, change '1 day ago' to 'yesterday'); but even with full localisation, I’d still be unlikely to use RelativeTimeFormat.)
const now = Temporal.now.absolute();
const then = Temporal.Absolute.from(
'1989-11-09T22:45:00+0100[Europe/Berlin]',
);
const sinceThen = now.difference(then);
sinceThen.toLocaleString('en');
1: https://tc39.es/proposal-temporal/docs/duration.html#toLocal...If you want those formatted values to be consistent with the rest of your app, you will need this anyway.
You app does support localisation right?
Also: there’s no guarantee a browser would have the same localisation as your app (for instance German-language browser, English website).
You really have to do this 100% yourself in your app if you want the result to look right.